Looking for a binreloc format
Sun May 1 18:28:00 GMT 2011
I was wondering whether binutils support an executable format
that is like “binary” but with dynamic base, i.e. a variable
-Ttext argument. I’m thinking of something like the DOS .exe
format, which had a list of “locations to patch” with the base
in the header.
Reason I’m asking: I want to make a bare-metal programme (boot
loader) relocatable but PIC/PIE isn’t going to help me there.
It’s developed on i386 for i386, and using gas’ intel_syntax
for the asm part and GCC for everything else. Currently I have
a fixed base (using “ld -nostdlib -Bstatic --no-undefined
-Ttext 0x40000 -N -noinhibit-exec -Wl,-O2 *.o $LIBS -o boot”
to link), but I want to change that.
I can prepend some small asm code that just walks a list of
offsets (relative to the file begin would be perfect) and
adds the linear base address there (I wonder whether having
more than one relocation type is needed _at all_, PC-relative
can be made .text-relative because this is in the end a variant
of the binary output format with final linking; only the width
(16 vs. 32 bit) might be an issue… currently I use only 32-bit
relocations, whan ld warns about something I’ve changed the
construct, e.g. “mov ax,[foo]” is now “mov ebx,offset foo” plus
“mov ax,[ebx]” to get the 32-bit relocation).
Any insight (even “you’re stupid, go away”) welcome.
(Crazy idea: use ld -Ttext 0 + ld -Ttext 0xdeadbeef, then make
a binary diff between these two in some kind of script, output
all locations that differ. Argh. You see why I’m asking here now?)
> Hi, does anyone sell openbsd stickers by themselves and not packaged
> with other products?
No, the only way I've seen them sold is for $40 with a free OpenBSD CD.
-- Haroon Khalid and Steve Shockley in gmane.os.openbsd.misc
More information about the Binutils