as / ld problem/question
Mon Jan 20 22:06:00 GMT 2003
I am new to this messageboard and the gnu/binutils environment, so
please forgive me if this question is obvious.
Here is the basic idea of the pipeline I would like to write.
I work with embedded systems with small memory footprints and so I would
like to offline compile and partially link data such that it resides in
a nice contiguous block that is relocatable.
I will then write a small relocation loader which will take a section
table with a relocation offset table and run-time patch addresses upon
load. I can't use the gnu compiler for the embedded run-time code
because there are already compilers/linkers for for me to use, so that
means I need to be able to write my own relocation code.
So in a nutshell: I want to have a pipeline that takes a bunch of
assembled data files, links them together and emits a relocatable ELF
file. I will write a tool on top of the final output that strips the
file down to what I specifically need. I will write a run-time loader
with relocation to load the file at an arbitrary address.
Rather than reinvent the wheel and write a relocatable assembler/linker
for the purposes of compiling data (not code), I would like to us 'as'
and 'ld'. Again, I might add this is my first experience with gnu. I
normally code with Microsoft products. :|
I have downloaded the cygwin package and after a few tests I have found
that 'ld' does indeed support relocatable hunks so all the information I
need is in the output. However, the output files are quite verbose,
even with most information stripped out via the command line options,
and besides I need to get the files as small as possible, so I intend to
write my own stripping tool which gets the file down to exactly what I
Some problems I have encountered thus far are:
1. I can't seem to output an ELF file from the Win32 'ld' even after
putting '-format -elf32-little' on the 'ld' command line. This is the
most frustrating. 'objcopy' seems to do it, but I need both little/big
endian assembled/linked output and I can't seem get all combinations.
The linker SAYS it can output ELF files. 2. It would appear that there
is a fair amount of documentation on the .ELF format, but I can't find
ANY read/write libraries. 3. I can't seem to find documentation or code
on the GNU relocation method. 'dllopen' is the function I want I think.
Any advice you might have would be greatly appreciated.
More information about the Binutils