linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Paul Mackerras <paulus@samba.org>
Cc: ppcdev <linuxppc-dev@ozlabs.org>,
	naren@linux.vnet.ibm.com, Milton Miller <miltonm@bga.com>
Subject: Re: [RFC v3 PATCH 6/4] Use LOAD_REG_IMMEDIATE macros
Date: Tue, 22 Jul 2008 19:13:10 +0200	[thread overview]
Message-ID: <cd6804d0f01b442f1c9695c0e87c9b00@kernel.crashing.org> (raw)
In-Reply-To: <18565.32839.382335.638503@cargo.ozlabs.ibm.com>

>> All of the variables references through @got translated into 
>> relocation
>> type R_PPC64_GOT16_DS entries. All these entries correspond to one of
>> the above entries in the .got section. But none of the entries in .got
>> section are relocated.
>
> If that last statement is really true, then that would be an absolute
> show-stopper, since you're not going to stop the compiler generating
> loads from the TOC to get addresses of things.
>
> However, I don't think it's true.  I compiled up a kernel using
> --emit-relocs on the final link, and with readelf -e I can see a
> .rela.got section containing a bunch of R_PPC64_ADDR64 relocs for
> entries in the .got section.
>
> So the problem appears to be either just that you are ignoring
> R_PPC64_ADDR64 relocs, or else that your relocs.c program has a bug
> and isn't seeing the .rela.got section.

I analysed this further.

.rela.got does have lots of relocs in it, but _not_ for relocations
create with @got in the assembler code.  GCC never does this AFAICS,
it explicitly creates a TOC entry and uses that.

So, the workaround would be to manually create TOC entries in the
LOAD_REG_ADDR code as well.  I'll work on that, feel free to beat me
to it of course.

>> Now I have two options left:
>> 1. Check for R_PPC64_GOT16_DS entries and check whether the contents
>> addressed by r2+offset is relocated or not and apply relocation if 
>> its not.
>> 2. Change all LOAD_REG_ADDR macros to LOAD_REG_IMMEDIATE. This I have
>> already done.
>
> I was trying to point out that this can't possibly be a viable
> solution to the problem, because most of the TOC loads in the binary
> are generated by the C compiler, and only a few of them come from use
> of the LOAD_REG_ADDR macro in assembly code.

binutils has a problem only with the @gotXXX relocations, where the
_linker_ creates the GOT entry (it doesn't emit a reloc for -emit-relocs
in that case).


Segher

  reply	other threads:[~2008-07-22 17:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-17 18:33 [RFC v3 PATCH 0/4] Relocatable kernel support for PPC64 Mohan Kumar M
2008-07-17 18:40 ` [RFC v3 PATCH 1/4] Extract list of relocation offsets Mohan Kumar M
2008-07-17 20:06   ` Benjamin Herrenschmidt
2008-07-18  5:32     ` Mohan Kumar M
2008-07-18 17:00       ` Milton Miller
2008-07-21 19:17         ` Mohan Kumar M
2008-07-22  6:29           ` Paul Mackerras
2008-07-22  7:58             ` Mohan Kumar M
2008-07-21 19:20         ` [RFC v3 PATCH 2/4] Build files needed for relocation Mohan Kumar M
2008-07-21 19:21         ` [RFC v3 PATCH 3/4] Apply relocation Mohan Kumar M
2008-07-21 19:23         ` [RFC v3 PATCH 4/4] Relocation support Mohan Kumar M
2008-07-21 19:25         ` [RFC v3 PATCH 5/4] Relocation support for kdump kernel Mohan Kumar M
2008-07-21 19:26         ` [RFC v3 PATCH 6/4] Use LOAD_REG_IMMEDIATE macros Mohan Kumar M
2008-07-22  2:03           ` Paul Mackerras
2008-07-22  4:37             ` Mohan Kumar M
2008-07-22  6:37               ` Paul Mackerras
2008-07-22 17:13                 ` Segher Boessenkool [this message]
2008-07-17 18:42 ` [RFC v3 PATCH 2/4] Build files needed for relocation support Mohan Kumar M
2008-07-17 18:45 ` [RFC v3 PATCH 3/4] Apply relocation info to vmlinux Mohan Kumar M
2008-07-17 18:48 ` [RFC v3 PATCH 4/4] Relocation support Mohan Kumar M
2008-07-18 17:48   ` Segher Boessenkool
2008-07-21  9:11     ` Mohan Kumar M

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=cd6804d0f01b442f1c9695c0e87c9b00@kernel.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=miltonm@bga.com \
    --cc=naren@linux.vnet.ibm.com \
    --cc=paulus@samba.org \
    /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 NNTP newsgroup(s).