diff options
author | Jan Beulich <jbeulich@suse.com> | 2023-08-25 14:56:44 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2023-08-25 14:56:44 +0200 |
commit | 67694446f772ae95d330419eb6d01e38e6d24612 (patch) | |
tree | 21119de766ad7554bd06371b5713ab4f58917c96 /gas | |
parent | 183440b0aa1cd752c324a2f4c16a620bd938d9ad (diff) | |
download | binutils-67694446f772ae95d330419eb6d01e38e6d24612.zip binutils-67694446f772ae95d330419eb6d01e38e6d24612.tar.gz binutils-67694446f772ae95d330419eb6d01e38e6d24612.tar.bz2 |
bfd: correct relocation handling for objcopy COFF -> ELF
While documented to not be reliable, it is still odd for objcopy to
silently produce bad output when converting COFF/PE object files to ELF
ones. The issue there is that relocation addends all are screwed up by
subtracting the symbol's section offset. In the COFF/PE world, to my
knowledge, section contents stores the addends alone, not the result of
symbol value plus addend. Hence the compensation talked about in a
comment ahead of the sole use site of CALC_ADDEND() may need to account
for the VMA (which is always zero for object files anyway), but not for
the symbol value.
The coff-sh.c adjustment is based upon guessing that behavior there is
the same. Note also how coff-aarch64.c short-circuits CALC_ADDEND()
altogether, which may suggest that a much simpler macro might do for the
COFF_WITH_PE case in the three arch-specific files touched here.
For (at least) Arm/WinCE this actually results in more appropriate
objdump output as well, as can be seen in the one testcase which has its
expectations adjusted (the generated binary doesn't change).
Diffstat (limited to 'gas')
-rw-r--r-- | gas/testsuite/gas/arm/wince.d | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gas/testsuite/gas/arm/wince.d b/gas/testsuite/gas/arm/wince.d index e5bac1d..e7afbed 100644 --- a/gas/testsuite/gas/arm/wince.d +++ b/gas/testsuite/gas/arm/wince.d @@ -15,11 +15,11 @@ Disassembly of section .text: 0+008 <global_sym\+0x4> e1a00000 nop @ \(mov r0, r0\) 0+00c <global_sym\+0x8> e1a00000 nop @ \(mov r0, r0\) 0+010 <global_sym\+0xc> eafffffb b f+ff8 <global_sym\+0xf+ff4> - 10: ARM_26D global_sym-0x4 + 10: ARM_26D global_sym 0+014 <global_sym\+0x10> ebfffffa bl f+ff4 <global_sym\+0xf+ff0> - 14: ARM_26D global_sym-0x4 + 14: ARM_26D global_sym 0+018 <global_sym\+0x14> 0afffff9 beq f+ff0 <global_sym\+0xf+fec> - 18: ARM_26D global_sym-0x4 + 18: ARM_26D global_sym 0+01c <global_sym\+0x18> eafffff8 b 0+004 <global_sym> 0+020 <global_sym\+0x1c> ebfffff7 bl 0+004 <global_sym> 0+024 <global_sym\+0x20> 0afffff6 beq 0+004 <global_sym> |