Page 1 of 1
Trouble with LD (unknown option: -T)
Posted: Sat Jul 19, 2008 9:04 pm
by osdf_1
Hi, I'm trying to use a linker script with ld, and I was told that the '-T' option was used to provide one. But when I tried it I got an error saying that the '-T' option doesn't exist. Here's what I did:
>ld -T link.ld -o kernel.bin start.o
And here's what I got:
ld: unknown option: -T
So how can I provide a linker script?
BTW I'm using a Leopard iMac
Re: Trouble with LD (unknown oprtion: -T)
Posted: Sat Jul 19, 2008 9:14 pm
by Zenith
Very strange...
First, try doing -Tlink.ld instead of -T link.ld (it might work...). Also check that link.ld actually exists.
If that doesn't work, do ld --help and see if the -T option is listed. If it isn't, get a different/newer linker.
Then do ld --version and give us the output.
Hope this helps!
Re: Trouble with LD (unknown option: -T)
Posted: Sat Jul 19, 2008 9:26 pm
by osdf_1
I got:
ld: unknown option: -Tlinker.ld
when using:
> ld -Tlinker.ld -o kernel.bin start.o
and:
ld: unknown option: --version
when using:
> ld --version
I also checked and linker.ld does exist. What should I do?
Oh, and:
>ld -v
outputs:
@(#)PROGRAM:ld PROJECT:ld64-84.3
Re: Trouble with LD (unknown option: -T)
Posted: Sat Jul 19, 2008 9:27 pm
by Alboin
Try 'ld -v', and if not, 'man ld'.
Re: Trouble with LD (unknown option: -T)
Posted: Sat Jul 19, 2008 9:30 pm
by osdf_1
>ld -v
outputs:
@(#)PROGRAM:ld PROJECT:ld64-84.3
And I couldn't find -T in the man page.
Re: Trouble with LD (unknown option: -T)
Posted: Sat Jul 19, 2008 9:51 pm
by Zenith
You're not using GNU ld, you're using something else... I'm assuming this is the linker that came with Leopard? Apple should know better
.
Download and compile the latest GNU binutils, which should have modern, functional copies of ld, as, objdump, and other goodies. They may also have a binary distribution for Mac, if you have trouble with compilation...
Re: Trouble with LD (unknown option: -T)
Posted: Sat Jul 19, 2008 9:54 pm
by thepowersgang
Try using the long version of the script command --script that might work.
If not run
and try to find the script option.
Re: Trouble with LD (unknown option: -T)
Posted: Sat Jul 19, 2008 10:57 pm
by osdf_1
Well I couldn't install GNU binutils, so I looked up the equivalent for -T, which is -exported_symbols_list (I think). But I think the script file should be written differently. Here's what I did:
> ld -exported_symbols_list linker -arch i386 -o kernel.bin start.o
And I got:
Code: Select all
ld warning: in start.o, file is not of required architecture
Undefined symbols:
"ENTRY(start)", referenced from:
-exported_symbols_list command line option
".bss : AT(phys + (bss - code))", referenced from:
-exported_symbols_list command line option
"code = .;", referenced from:
-exported_symbols_list command line option
"end = .;", referenced from:
-exported_symbols_list command line option
"OUTPUT_FORMAT("binary")", referenced from:
-exported_symbols_list command line option
".data : AT(phys + (data - code))", referenced from:
-exported_symbols_list command line option
"{", referenced from:
-exported_symbols_list command line option
"}", referenced from:
-exported_symbols_list command line option
".text phys : AT(phys) {", referenced from:
-exported_symbols_list command line option
"bss = .;", referenced from:
-exported_symbols_list command line option
"SECTIONS", referenced from:
-exported_symbols_list command line option
"data = .;", referenced from:
-exported_symbols_list command line option
"phys = 0x00100000;", referenced from:
-exported_symbols_list command line option
". = ALIGN(4096);", referenced from:
-exported_symbols_list command line option
ld: symbol(s) not found
Here's my script, anyone knows what would be Apple ld's equivalent?
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
Re: Trouble with LD (unknown option: -T)
Posted: Sun Jul 20, 2008 10:48 am
by JamesM
Apple use their own toolchain that only has loose compatibility with the GNU tools. Given the bug I found in their assembler's lexer the other week I wouldn't trust that toolchain as far as I could throw it.
You can get the GNU tools at
ftp://ftp.gnu.org.
Re: Trouble with LD (unknown option: -T)
Posted: Mon Jul 21, 2008 8:33 am
by Combuster