Ok, i have a shell script to link a C and ASM file together, that's all wel, but it links/compiles incorrectly, either way, my script is like so:
---
#!/bin/csh
nasm -f elf $1.s -o obj/$1_a.o
if ( $? != 0 ) then
echo NASM: Error!
exit 1
endif
gcc -ffreestanding -static -c $1.c -o obj/$1_c.o
if ( $? != 0 ) then
echo GCC: Error!
exit 1
endif
ld -o obj/$1 -static -Ttext 0x600-e 0x0 obj/$1_a.o obj/$1_c.o
if ( $? != 0 ) then
echo LD: Error!
exit 1
endif
trimbin obj/$1 obj/$1.sect #trim elf out of binary
sectbin obj/$1.sect $2 #make binary confom to sectors, 512, 1024..
exit 0
---
now.. i linked a file with it (a variation on it without the ASM parts), and it reports a 4 kb file size (and the precompiled binary was like 72 bytes...) what the heck!? thanks in advance, if i get any help
Linking..
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Linking..
this "4K incrementation" might be due to some default padding in your binary fileformat ... (very common with ELF, for instance)
Re:Linking..
it['s not so much elf, because i have the trimbin script to make it a flat-binary... come to think of it, NOTHING 9i have made with that script has worked, (like character prin6ting) but dos debug gave me correct assembly..
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Linking..
imho, grub REQUIRE elf format ... and i see nothing in your script that enforces a flat binary .. try to use objdump -x to see where your bytes come from: it could be a relocation table, a padding header, debug symbols, whatever ...
Re:Linking..
I tried an ELF binary with grub (it didnt work), and the trimbin line enforces the binary (it contains the objcopy command, but i reference it for like... instead of having to alter all the files to make a change (at least to the objcopy line))