This is the mail archive of the binutils@sources.redhat.com 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]

Change to GOT initialization?


I'm not sure exactly when this happened (sometime between 2.11.2
and now), but the way the GOT is initialized has changed in a way
that is breaking the self-relocation code in NetBSD's ELF rtld (at
least on PowerPC).

The rtld is linked with "-Bshareable -Bsymbolic", and under 2.11.2
this produced a GOT that contained base-relative addresses:

ld.elf_so:     file format elf32-powerpc

Contents of section .got:
 9e24 4e800021 0000a008 00000000 000087d0  N..!............
 9e34 00008938 00008974 00003bf8 0000a078  ...8...t..;....x
 9e44 0000a0cc 000089bc 000089c8 000089d4  ................
 9e54 000089e4 000089f4 00008a00 00008a08  ................
 9e64 00008a18 00008a24 00008a34 00008a38  .......$...4...8
 9e74 00008a44 00008a64 00008a7c 00008aa4  ...D...d...|....
 9e84 00008ac8 00008b04 00008b30 00008b5c  ...........0...\
 9e94 00008bbc 00008b8c 00008b90 0000a0ac  ................
 9ea4 0000a2cc 0000a0b0 0000a0a4 0000a0a8  ................
 9eb4 00008bc4 00008be0 00008bf8 0000a344  ...............D
 9ec4 0000882c 00008bfc 00008c04 00008c18  ...,............
 9ed4 00008c2c 00008c30 00008c38 00008c40  ...,...0...8...@
 9ee4 00008c60 00008c80 00008c9c 00008cb4  ...`............
 9ef4 00008cdc 00008d04 00008d1c 00008d34  ...............4
 9f04 00008d5c 00008d78 00008d8c 00008da0  ...\...x........
 9f14 00008db4 00008db8 00008dd4 00008df0  ................
 9f24 00008e14 00008e18 00008e40 00008e74  ...........@...t
 9f34 00008e94 00008880 000088e0 00008f48  ...............H
 9f44 00008f4c 00008f50 00008f54 00008f60  ...L...P...T...`
 9f54 00008f64 00008f88 00008fa0 00008fa4  ...d............
 9f64 00008fa8 00008fd0 00008ff4 0000901c  ................
 9f74 00009044 00009060 000099b8 000099c8  ...D...`........
 9f84 0000a070 000039fc 0000a07c 0000a008  ...p..9....|....
 9f94 0000a0b4 000036c4 0000a080 00003840  ......6.......8@
 9fa4 0000a084 0000a088 0000a068 0000a08c  ...........h....
 9fb4 0000a060 00003470 00009af4 00003370  ...`..4p......3p
 9fc4 00002718 000026cc 0000343c 0000a468  ..'...&...4<...h
 9fd4 0000272c 0000a090 0000a05c 0000a094  ..',.......\....
 9fe4 0000a53c 0000a098 0000a54c 00009e28  ...<.......L...(
 9ff4 0000a09c 0000a058 0000a074 0000a0a0  .......X...t....
 a004 00000000                             ....            

With binutils-cvs from a couple of days ago:

ld.elf_so:     file format elf32-powerpc

Contents of section .got:
 9dac 4e800021 00009f90 00000000 00000000  N..!............
 9dbc 00000000 00000000 00000000 00000000  ................
 9dcc 00000000 00000000 00000000 00000000  ................
 9ddc 00000000 00000000 00000000 00000000  ................
 9dec 00000000 00000000 00000000 00000000  ................
 9dfc 00000000 00000000 00000000 00000000  ................
 9e0c 00000000 00000000 00000000 00000000  ................
 9e1c 00000000 00000000 00000000 00000000  ................
 9e2c 00000000 00000000 00000000 00000000  ................
 9e3c 00000000 00000000 00000000 00000000  ................
 9e4c 00000000 00000000 00000000 00000000  ................
 9e5c 00000000 00000000 00000000 00000000  ................
 9e6c 00000000 00000000 00000000 00000000  ................
 9e7c 00000000 00000000 00000000 00000000  ................
 9e8c 00000000 00000000 00000000 00000000  ................
 9e9c 00000000 00000000 00000000 00000000  ................
 9eac 00000000 00000000 00000000 00000000  ................
 9ebc 00000000 00000000 00000000 00000000  ................
 9ecc 00000000 00000000 00000000 00000000  ................
 9edc 00000000 00000000 00000000 00000000  ................
 9eec 00000000 00000000 00000000 00000000  ................
 9efc 00000000 00000000 00000000 00000000  ................
 9f0c 00000000 00000000 00000000 00000000  ................
 9f1c 00000000 00000000 00000000 00000000  ................
 9f2c 00000000 00000000 00000000 00000000  ................
 9f3c 00000000 00000000 00000000 00000000  ................
 9f4c 00000000 00000000 00000000 00000000  ................
 9f5c 00000000 00000000 00000000 00000000  ................
 9f6c 00000000 00000000 00000000 00000000  ................
 9f7c 00000000 00000000 00000000 00000000  ................
 9f8c 00000000                             ....            

The way we compute our relocation base is:

        bl      _GLOBAL_OFFSET_TABLE_@local-4
        mflr    %r31                    # r31 = (real) GOT
        lwz     %r30,_GLOBAL_OFFSET_TABLE_@got(31)
                                        # the linker thought GOT were ...
        subf    %r4,%r30,%r31           # r4 = relocbase

...but this falls over completely, because 0 ends up being loaded
info %r30, so we can't compute the relocbase (nor can we compute
the real address of _DYNAMIC, since we don't know the relocbase to
add to the base-relative offset in _DYNAMIC's GOT entry).

So, I guess I have two questions:

	1. Can anyone tell me when this change was made, and why?

	2. Can anyone suggest a way for me to deal with the problem
	   (I guess the question really is: Can anyone suggest another
	   way for me to compute the relocbase?)

Thanks much...

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>


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