24 January 2020, 22:47 | #1 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
vlink always links all modules from library
In my utillity library, I put each function into a seperate source file, as I expected that at linktime, only the modules will be included which are actually referenced.
Now I noticed that always the whole library seems to be linked into the final executable, even if the code is never called, so I wonder what I am doing wrong? An example can be found here: https://github.com/skeetor/amiga-uti.../from_decu16.s All modules use Code:
section .text,code Should I put each module into a separate section? The linker command is this: Code:
/opt/amiga/bin//vlink -b amigahunk -Bstatic -nostdlib CMakeFiles/Choplifter.dir/main.s.o CMakeFiles/Choplifter.dir/intro/CopperAnimation.s.o -o ../bin/Choplifter.exe /opt/amiga/utils/lib/libAmigaUtils.a I attached a sample binary where you can see that the symbols are included, like 'fromDecimalU32' but this function is nowhere called in my code. When I look in Monam I can see that not only the symbol is lsted, but the code is also there. Last edited by sparhawk; 24 January 2020 at 22:53. |
24 January 2020, 23:00 | #2 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,292
|
Quote:
How do you build your library then? If just by linking the binaries, then the linker will put them into one hunk. You either need an object module librarian, such as the SAS/C "OML" utility, or a specialized linker for that which does not merge all the hunks. |
|
24 January 2020, 23:09 | #3 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
The library itself is just linked with 'ar'
Code:
amiga-ar qc ../lib/libAmigaUtils.a snprintf.cpp.o vsnprintf.cpp.o SystemTakeover.s.o WaitRaster.s.o DebugPowerLED.s.o GFXLibrary.s.o MouseHelper.s.o dos/DOSLibrary.s.o dos/WriteString.s.o strlen.s.o from_decu16.s.o from_decu32.s.o from_decs.s.o to_decu16.s.o to_decs16.s.o to_decu32.s.o to_decs32.s.o mem/memcpyl.s.o mem/memcpyw.s.o mem/zcopyb.s.o mem/zcopyw.s.o mem/zcopyl.s.o copper/CreateCopperList.s.o copper/CreateCopperListC.s.o math/div32.s.o math/mult32.s.o amiga-ranlib ../lib/libAmigaUtils.a This library is then linked as I wrote above. Code:
vlink -b amigahunk -Bstatic -nostdlib CMakeFiles/Choplifter.dir/main.s.o CMakeFiles/Choplifter.dir/intro/CopperAnimation.s.o -o ../bin/Choplifter.exe /opt/amiga/utils/lib/libAmigaUtils.a |
25 January 2020, 22:19 | #4 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,525
|
Don't know what your amiga-ar is creating. Probably a Unix ar-library? Have a look into the map file (-M) to see what vlink has done with it.
Unix libraries are supported by vlink, but you have to specify it as a library (-l option). You added it as another object file to the command line, so it is regarded as an object file instead as a library. In your case, you may try: vlink ... -L../lib -lAmigaUtils BTW, making a real hunk-format linker-library for AmigaOS is really simple: join obj1.o objN.o as mylib.lib(or use 'cat' when under Unix) Then link with: vlink ... -Lpathtomylib -lmylib |
25 January 2020, 22:26 | #5 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
I checked the manual for vlink and found an option which seems to do what I wanted:
Code:
-gc-all My 'amiga-ar' ist just a wrapper for bebbos m68k tools, because on some of them I need to filter certain parameters which are not supported, but are used by CMake (That's mostly for gcc though). |
25 January 2020, 22:30 | #6 | |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
Quote:
Thanks for pointing that out. Since the linked binary always worked, I haven't noticed that. I wrote some CMake modules to support m68k-amigaos from bebbo, so it seems I have some of the compiler definition scripts wrong because if I had set it up correct, CMake should have created that library parameter. |
|
25 January 2020, 23:40 | #7 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
After fixing the issue, that my library was not linked like a library, it turned out, that this was also the reason why it didn't throw away unreferenced modules. I didn't need the '-gc-all' switch after that fix and binaries are now as small as they should be.
|
26 January 2020, 01:15 | #8 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,525
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
vasm / vlink undefined symbol | zeGouky | Coders. General | 2 | 02 January 2019 08:49 |
Preventing hunk merger with vlink | Hedeon | Coders. C/C++ | 2 | 24 August 2018 14:40 |
Trying out vlink and vasm | cla | Coders. General | 2 | 30 September 2016 20:30 |
VLINK multiple VASM objects | roondar | Coders. Asm / Hardware | 2 | 24 April 2016 01:03 |
Brain Killer Aminet links changed (and a question about Aminet links) | Korodny | HOL data problems | 0 | 26 November 2009 21:21 |
|
|