[PR20402][LD][AARCH64]Don't emit RELATIVE relocation for absolute symbols which are resolved at static linking time.

Renlin Li renlin.li@foss.arm.com
Tue Feb 6 13:17:00 GMT 2018

Hi all,

For absolute symbols which are forced local or not dynamic, the ABS relocation
should be resolved at static linking time.

Originally, an RELATIVE/ABS relocation will be generated even for absolution symbols
for the dynamic linker to resolve.

For the testcase with the patch, before the change, two R_AARCH64_RELATIV relocations
will be generated.

The relocation will be changed into R_AARCH64_NONE.  It is not possible to
remove the relocations totally.
At the time of allocating dynamic relocs space, the symbol information is not
finalized. It is not safe to not allocating space for the relocation with the
information available at that time.

For example, symbol agasint '.' will be initially defined in ABS section, but
later updated as section relative symbol. A relocation is needed for this case.

For _GLOBAL_OFFSET_TABLE_ and _DYNAMIC symbols, they are initially created as section relative
and forced local. So for those two symbol, a RELATIVE relocation will be generated.
They are later marked as absolute. This behavior is not changed with the patch here.

aarch64 binutils cross/native regression test Okay. Linux kernel link Okay.
Okay to commit?



2018-02-06  Renlin Li  <renlin.li@arm.com>

         PR ld/20402
	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Check absolute symbol,
         and don't emit relocation in specific case.


2018-02-06  Renlin Li  <renlin.li@arm.com>

         PR ld/20402
	* testsuite/ld-aarch64/aarch64-elf.exp: Run new test.
	* testsuite/ld-aarch64/pr20402.s: New.
	* testsuite/ld-aarch64/pr20402.d: New.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rb.patch
Type: text/x-patch
Size: 3013 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20180206/36cbb2ea/attachment.bin>

More information about the Binutils mailing list