Trouble with LD (unknown option: -T)
Trouble with LD (unknown option: -T)
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
>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)
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!
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!
"Sufficiently advanced stupidity is indistinguishable from malice."
Re: Trouble with LD (unknown option: -T)
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
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
Last edited by osdf_1 on Sat Jul 19, 2008 9:29 pm, edited 2 times in total.
Re: Trouble with LD (unknown option: -T)
Try 'ld -v', and if not, 'man ld'.
C8H10N4O2 | #446691 | Trust the nodes.
Re: Trouble with LD (unknown option: -T)
>ld -v
outputs:
@(#)PROGRAM:ld PROJECT:ld64-84.3
And I couldn't find -T in the man page.
outputs:
@(#)PROGRAM:ld PROJECT:ld64-84.3
And I couldn't find -T in the man page.
Re: Trouble with LD (unknown option: -T)
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...
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...
"Sufficiently advanced stupidity is indistinguishable from malice."
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: Trouble with LD (unknown option: -T)
Try using the long version of the script command --script that might work.
If not run and try to find the script option.
If not run
Code: Select all
ld --help
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Re: Trouble with LD (unknown option: -T)
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:
Here's my script, anyone knows what would be Apple ld's equivalent?
> 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
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)
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.
You can get the GNU tools at ftp://ftp.gnu.org.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Trouble with LD (unknown option: -T)
Or preferrably, GCC Cross-Compiler