This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Binutils 2.28 on PowerPC: dangerous relocation: generic linker can't handle R_PPC_SECTOFF_HA
- From: Alan Modra <amodra at gmail dot com>
- To: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- Cc: binutils <binutils at sourceware dot org>
- Date: Wed, 15 May 2019 13:39:46 +0930
- Subject: Re: Binutils 2.28 on PowerPC: dangerous relocation: generic linker can't handle R_PPC_SECTOFF_HA
- References: <118142359.142184.1496311674176.JavaMail.zimbra@embedded-brains.de> <20170601104238.GD8842@bubble.grove.modra.org> <130569507.142235.1496314732401.JavaMail.zimbra@embedded-brains.de> <48291758.142314.1496315282926.JavaMail.zimbra@embedded-brains.de> <20170601140636.GN8842@bubble.grove.modra.org> <1820249782.143803.1496380818607.JavaMail.zimbra@embedded-brains.de> <9a27522e-6a4e-ed0b-3ac4-cb30c027268d@embedded-brains.de> <20190508084153.GV3195@bubble.grove.modra.org> <ddf8249a-9e68-ae42-4591-603dd02876da@embedded-brains.de>
On Tue, May 14, 2019 at 02:42:36PM +0200, Sebastian Huber wrote:
> Lets look at the following assembler code in the .text input section:
>
> https://git.rtems.org/rtems/tree/bsps/powerpc/motorola_powerpc/bootloader/head.S
>
> /* Call the routine to fill boot_data structure from residual data.
> * And to find where the code has to be moved.
> */
> lis r3,__size@sectoff@ha
> addi r3,r3,__size@sectoff@l
>
> This symbol is defined by the linker script:
>
> https://git.rtems.org/rtems/tree/bsps/powerpc/motorola_powerpc/bootloader/ppcboot.lds
>
> |.bss : { *(.sbss) *(.bss) . = ALIGN(4); } __bss_words = SIZEOF(.bss)>>2;
> __size = . ; /DISCARD/ : { *(.comment) } }|
>
>
> I built the latest Binutils and invoked ld in GDB. I set a break point to
> _bfd_final_link_relocate(). Here I get this:
[snip]
> (gdb) p sec->output_section ->name
> $2 = 0x89cc60 ".bss"
>
> Why is the output section .bss for __size and not *ABS*?
See ldexp.c set_sym_sections and ldlang.c section_for_dot. The linker
ties assignments to their nearest output section statement because
that works out best in most real-world usage. For example, symbols
like "_end" should not be SHN_ABS due to their use in position
independent code invariably wanting the value relocated by the base
address of the shared library or PIE.
We do have a way of forcing SHN_ABS symbols in scripts:
__size = ABSOLUTE (.);
> If I do this with the latest Binutils 2.19 branch. I get:
[snip]
> (gdb) p sec->output_section ->name
> $2 = 0x4acd54 "*ABS*"
Yes, well, this is why many ld.so implementations must relocate
SHN_ABS symbols. Weird but necessary given older linker behaviour.
The source you show is slightly crazy too. Why use @sectoff when
expecting a SHN_ABS symbol?
--
Alan Modra
Australia Development Lab, IBM