Subject: Re: Dynamic linking is go (again)
To: Jason Thorpe <>
From: Marcus Comstedt <>
List: port-sh3
Date: 07/04/2003 17:46:49
Marcus Comstedt <> writes:

> [...]  Right now I'm thinking maybe ld will automatically
> add exports of symbols in the main binary if it can see that they are
> being used from a shared object?  That would explain the behaviour,
> but it would be a bit underhanded of ld...  :-)  I'll investigate
> further.

Yup, this seems to be the true explanation.  func2 is the function in
the main binary that is called from the shared object:

Program using dlopen linked without -E:

doreimon:~/sohack% objdump -T prog | grep "g    DF .text"
00400fd0 g    DF .text  0000007c __fixunsdfsi
00401050 g    DF .text  0000006c __fixunssfsi

Program linked against the shared object, but still without -E:

doreimon:~/sohack% objdump -T prog | grep "g    DF .text"
00400fa0 g    DF .text  0000007c __fixunsdfsi
00400e80 g    DF .text  0000005c func2
00401020 g    DF .text  0000006c __fixunssfsi

dlopen program linked with -E:

doreimon:~/sohack% objdump -T prog | grep "g    DF .text"
00400d2c g    DF .text  0000003c _dladdr
00400c70 g    DF .text  0000003c _dlclose
004010b0 g    DF .text  0000007c __fixunsdfsi
00400cac g    DF .text  0000003c _dlsym
00400c34 g    DF .text  0000003c _dlopen
00400ce8 g    DF .text  00000044 _dlerror
00400ab6 g    DF .text  000000ba _start
00400f5c g    DF .text  00000148 main
00400f00 g    DF .text  0000005c func2
00400b8e g    DF .text  000000a6 _rtld_setup
00401130 g    DF .text  0000006c __fixunssfsi

Sneaky...  :-)

  // Marcus