Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

ld/ldlang: Fix linker relaxation failure if there are R_RISCV_ALIGN type relocations on RISC-V #185

Conversation

yiting16
Copy link

See bug report at https://sourceware.org/bugzilla/show_bug.cgi?id=25181

ld/
    * ldlang.c (lang_size_sections_1): split the call to
      size_input_section() to 2 parts to fix linker relaxation
      failure if there are R_RISCV_ALIGN type relocations on RISC-V
    * testsuite/ld-riscv-elf/ld-riscv-elf.exp: add a test case
    * testsuite/ld-riscv-elf/relax*: the test case files

…ype relocations on RISC-V

See bug report at https://sourceware.org/bugzilla/show_bug.cgi?id=25181

    ld/
        * ldlang.c (lang_size_sections_1): split the call to
          size_input_section() to 2 parts to fix linker relaxation
          failure if there are R_RISCV_ALIGN type relocations on RISC-V
        * testsuite/ld-riscv-elf/ld-riscv-elf.exp: add a test case
        * testsuite/ld-riscv-elf/relax*: the test case files
@Nelson1225
Copy link
Collaborator

Thanks for the report.

It is better to resolve the specific target issue in the target related files rather than the generic code. If you modify the generic code, then you have to make sure that your modification won't affect other ports.

I suppose that the default linker script won't cause this problem. See the _bfd_riscv_relax_call in the bfd/elfnn-riscv.c, we have already consider the maximum alignment for the cross output section boundaries. Your failed case will gather the different input "text" sections with different alignments into the same output section. I'm not sure whether this is a normal usage, but if we need to resolve this, then always consider the max alignment for the call relaxation may be a more suitable way.

Thanks
Best Regards
Nelson

@yiting16
Copy link
Author

@Nelson1225 Thank you for your guidance. I understand what you mean. Jim has created a patch, used the max alignment for the call relaxation as you said. So, I will close my pull request.

@yiting16 yiting16 closed this Nov 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants