ld -R does not always work correctly ??
Kristis Makris
kristis.makris@asu.edu
Sun Oct 26 06:42:00 GMT 2003
Hello,
I have also send this email to the mailing list on Oct 07 2003 but did
not receive a response. I am wondering if there's something wrong with
the way ld -R works.
I am trying to link an object file using the absolute memory addresses
found in another object file. The exact syntax I am using is:
$ ld -R ../../../../kernel/kernel-source-2.4.20.mod/vmlinux -r
dynreplace_scheduler_v3.o -o dynreplace_file.o
However some symbols found in dynreplace_scheduler_v3.o do not use the
absolute memory addressses found in vmlinux after linking. They just
remain undefined. Here are all the symbols in dynreplace_scheduler_v3.o
$ nm dynreplace_scheduler_v3.o
U __mmdrop
00000040 ? __module_description
00000000 ? __module_kernel_version
0000001d ? __module_license
U __switch_to
U aligned_data
00000000 d call_count.951
U default_ldt
00000000 t gcc2_compiled.
U init_task_union
U irq_stat
U jiffies
U kstat
U nr_running
U printk
U runqueue_head
00000000 T schedule_v3
00000320 T schedule_v3_endlabel
U set_ldt_desc
And here are a couple of symbols that are present in vmlinux but are
left undefined in the dynreplace_file.o:
$ nm ../../../../kernel/kernel-source-2.4.20.mod/vmlinux |grep -i
runqueue_head
c0208f88 d runqueue_head
]$ nm ../../../../kernel/kernel-source-2.4.20.mod/vmlinux |grep -i
aligned_data
c0263520 d aligned_data
$ nm dynreplace_file.o |grep -i runqueue_head
U runqueue_head
$ nm dynreplace_file.o |grep -i aligned_data
U aligned_data
Why would that happen ? All other undefined symbols in
dynreplace_scheduler_v3.o had the correct absolute memory addresses
referenced in the outputed dynreplace_file.o. The only difference I
noticed is that these two symbols are an extern struct (runqueue_head)
and an extern union(aligned_data). ld -R correctly uses the memory
addresses for int variables and functions. Is this a bug ?
Additionally, the output of using ld -R <file_to_consult> <file> always
includes the entire list of symbols from <file_to_consult>
even though not all of them may be needed, resulting in an object file
that includes unneeded symbols that need to be stripped out with some
manual scripting. Is it possible to add an additional flag that acts
just like -R but produces an output file that includes only symbols used
in <file> with the absolute memory addresses of <file_to_consult> ?
More information about the Binutils
mailing list