This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Still more trouble with ld
- From: Alex Buell <alex dot buell at munted dot org dot uk>
- To: binutils at sourceware dot org
- Date: Fri, 16 Jul 2010 16:17:59 +0100
- Subject: Still more trouble with ld
- Reply-to: alex dot buell at munted dot org dot uk
I was quite successful in getting the binary down to 510 bytes. Then I
moved a routine into the library archive, and the binary swelled up to
719 bytes!
It seems the linker is pulling everything into the binary file from the
library archive.
I tried using section directives with each assembly function, and used
the following linker script:
SECTIONS
{
.text : SUBALIGN(0)
{
*(.text)
*(.text.*)
}
}
This works quite well, keeps the main routine code at the top of the
binary and all the rest at the bottom of the binary.
Any ideas how I can make the ld linker discard routines not used? Here's
the link map generated as below. Please also cc me as I'm not on the
mailing list, thanks.
As you can see below, it should only link in print16 and discard the
rest of the routines from .text.io.*. Ideas?
Archive member included because of file (symbol)
libcommon.a(floppy16.o) stage1/boot.o (datasector)
libcommon.a(msdosfs.o) stage1/boot.o (load_root)
libcommon.a(io.o) stage1/boot.o (print16)
Memory Configuration
Name Origin Length Attributes
*default* 0x0000000000000000 0xffffffffffffffff
Linker script and memory map
.text 0x0000000000000000 0x2cf
*(.text)
.text 0x0000000000000000 0x11c stage1/boot.o
0x0000000000000003 BPB
.text 0x000000000000011c 0x0 libcommon.a(floppy16.o)
.text 0x000000000000011c 0x0 libcommon.a(msdosfs.o)
*(.text.*)
.text.floppy16.data
0x000000000000011c 0x9 libcommon.a(floppy16.o)
0x000000000000011e datasector
0x0000000000000120 cluster
.text.floppy16.CHStoLBA
0x0000000000000125 0x10 libcommon.a(floppy16.o)
0x0000000000000125 CHStoLBA
.text.floppy16.LBAtoCHS
0x0000000000000135 0x1a libcommon.a(floppy16.o)
0x0000000000000135 LBAtoCHS
.text.floppy16.SectorsRead
0x000000000000014f 0x3e libcommon.a(floppy16.o)
0x000000000000014f SectorsRead
.text.msdosfs.load_root
0x000000000000018d 0x28 libcommon.a(msdosfs.o)
0x000000000000018d load_root
.text.msdosfs.find_file
0x00000000000001b5 0x28 libcommon.a(msdosfs.o)
0x00000000000001b5 find_file
.text.msdosfs.load_fat12
0x00000000000001dd 0x16 libcommon.a(msdosfs.o)
0x00000000000001dd load_fat12
.text.msdosfs.load_file
0x00000000000001f3 0x1 libcommon.a(msdosfs.o)
0x00000000000001f3 load_file
.text.io.print16
0x00000000000001f4 0xe libcommon.a(io.o)
0x00000000000001f4 print16
.text.io.data 0x0000000000000202 0x2 libcommon.a(io.o)
.text.io.printchar32
0x0000000000000204 0x48 libcommon.a(io.o)
0x0000000000000204 printchar32
.text.io.print32
0x000000000000024c 0x25 libcommon.a(io.o)
0x000000000000024c print32
.text.io.MoveCursor
0x0000000000000271 0x30 libcommon.a(io.o)
0x0000000000000271 MoveCursor
.text.io.ClearScreen
0x00000000000002a1 0x22 libcommon.a(io.o)
0x00000000000002a1 ClearScreen
.text.io.GotoXY
0x00000000000002c3 0xc libcommon.a(io.o)
0x00000000000002c3 GotoXY
LOAD stage1/boot.o
LOAD libcommon.a
Address of section .text set to 0x0
OUTPUT(boot.bin binary)
--
http://www.munted.org.uk
One very high maintenance cat living here.