This is the mail archive of the binutils@sourceware.org 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]

Looking for a binreloc format


Hi,

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?)

bye,
//mirabilos
-- 
> 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


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