This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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

Re: How to make a portable toolchain?


Bin Zhou wrote:
> 
> The mixed linking works if I put -B everywhere with the linking options,
> like:
> 
> $binzhou>gcc -Bstatic -o my_binary <my_objs> -lc -Bdynamic -ldl -Bstatic

 I forgot to use the '-Wl,-Bdynamic' etc. in my example, which was my original
purpose...

 I understood from the FAQ that the '-Bdynamic' and the '-Bstatic' could be used
as 'mode-switchers' when linking. If they are given on the GCC-command line, it
is hard to say what happens on the linker command. Anyway there are the '-v' option
for 'gcc' and the '-verbose' option for the GNU linker, and these show what happens.

 Ok, my new suggestion would however to be to add the following:

   %{static:-Bdynamic -ldl -Bstatic} %{!static:-ldl}

after the '-lc' in the '*lib:'-spec in the 'specs'-file (The old one suggested only
the latter part)... Then the '-ldl' will be 'wrapped' between '-Bdynamic' and
'-Bstatic' on the command line for the linker.

> Unfortunately, the size of the target file created in this way is exactly
> the same as the size of target created by linking everything dynamically.

 I tried my new suggestion and the result was a little bigger than the static-only
executable for my 'tprintf' program, which doesn't use the 'dl*'-functions anywhere
(or the library functions it takes from 'libc.a').

 Directory of H:\usr\local\samples

02.11.2001  14:27               10 313 tst_sol2-d.x
02.11.2001  14:02              304 725 tst_sol2-s.x
06.11.2001  11:58              305 960 tst_sol2.x

 The 'objdump -p' shows it needing only the 'libdl.so.1' at run-time:

--------- clip ---------------
Dynamic Section:
  NEEDED      libdl.so.1
  INIT        0x1023c
  FINI        0x335e0
  HASH        0x100e8
  STRTAB      0x1019c
  SYMTAB      0x1011c
  STRSZ       0x70
  SYMENT      0x10
--------- clip ---------------

Cheers, Kai


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


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