From: Alan Modra <amodra@gmail.com>
To: Sebastian Huber <sebastian.huber@embedded-brains.de>
Cc: binutils <binutils@sourceware.org>
Subject: Re: Binutils 2.28 on PowerPC: dangerous relocation: generic linker can't handle R_PPC_SECTOFF_HA
Date: Wed, 15 May 2019 04:10:00 -0000 [thread overview]
Message-ID: <20190515040945.GA6820@bubble.grove.modra.org> (raw)
In-Reply-To: <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
next prev parent reply other threads:[~2019-05-15 4:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-01 10:07 Sebastian Huber
2017-06-01 10:42 ` Alan Modra
2017-06-01 10:58 ` Sebastian Huber
2017-06-01 11:07 ` Sebastian Huber
2017-06-01 14:06 ` Alan Modra
2017-06-02 5:19 ` Sebastian Huber
[not found] ` <9a27522e-6a4e-ed0b-3ac4-cb30c027268d@embedded-brains.de>
2019-05-08 8:42 ` Alan Modra
2019-05-14 12:42 ` Sebastian Huber
2019-05-15 4:10 ` Alan Modra [this message]
2019-05-16 9:29 ` Sebastian Huber
2019-05-16 14:05 ` Alan Modra
2019-05-17 5:20 ` Sebastian Huber
2019-05-20 4:57 ` Alan Modra
2019-05-27 8:43 ` Sebastian Huber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190515040945.GA6820@bubble.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=sebastian.huber@embedded-brains.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).