This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Binutils 2.28 on PowerPC: dangerous relocation: generic linker can't handle R_PPC_SECTOFF_HA


On Tue, May 07, 2019 at 10:30:40AM +0200, Sebastian Huber wrote:
> powerpc-rtems4.9-ld --version
> GNU ld (GNU Binutils) 2.19.1
> 
> With this LD version I can boot the application. The LD output is a binary
> file. I had to remove the OUTPUT_ARCH(powerpc) from ppcboot.lds.
> 
> Since at least Binutils 2.28, it no longer works:
> 
> powerpc-rtems5-ld -o ticker.ralf
> /build/git-build/b-any/powerpc-rtems5/mvme2100/lib/bootloader.o
> --just-symbols=ticker.exe -b binary rtems.gz -T
> ~/git-rtems-5/./bsps/powerpc/motorola_powerpc/bootloader/ppcboot.lds
> /build/git-build/b-any/powerpc-rtems5/mvme2100/lib/bootloader.o: in function
> `start':
> /home/EB/sebastian_h/git-rtems-5/c/src/lib/libbsp/powerpc/motorola_powerpc/bootloader/../../../../../../../bsps/powerpc/motorola_powerpc/bootloader/head.S:140:(.text+0x8a):
> dangerous relocation: generic linker can't handle R_PPC_SECTOFF_HA
> /home/EB/sebastian_h/git-rtems-5/c/src/lib/libbsp/powerpc/motorola_powerpc/bootloader/../../../../../../../bsps/powerpc/motorola_powerpc/bootloader/head.S:141:(.text+0x8e):

The truth is that linking to binary with 2.19 did not handle any of
the R_PPC_SECTOFF relocations correctly.  They were handled just like
the corresponding R_PPC_ADDR16 reloc, a fact that you can verify by
comparing the reloc howtos.  (Reloc howtos are used by the generic
linker to apply relocations.  When linking to powerpc ELF you'll be
using the code in ppc_elf_relocate_section instead.)  So the values
applied by 2.19 were symbol values rather than symbol values relative
to their output section.

I think that means your assembly code has compensated for the 2.19
linker behaviour by some means or other, and therefore crashes with a
fixed linker.

You'll probably find that using 2.19 to link to ELF then objcopy to
binary will also give you a "bad" output.

[snip]
> powerpc-rtems5-ld -o ticker.ralf
> /build/git-build/b-any/powerpc-rtems5/mvme2100/lib/bootloader.o
> --just-symbols=ticker.exe -b binary rtems.gz -T
> ~/git-rtems-5/./bsps/powerpc/motorola_powerpc/bootloader/ppcboot.lds
> powerpc-rtems5-ld: ticker.exe uses hard float,
> /build/git-build/b-any/powerpc-rtems5/mvme2100/lib/bootloader.o uses soft
> float
> powerpc-rtems5-ld: failed to merge target specific data of file ticker.exe

I guess you could argue that it's a bug to complain about
--just-symbols target specific data.

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]