Page 1 of 1

Linking..

Posted: Thu Sep 26, 2002 3:43 pm
by AvengerX
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

Re:Linking..

Posted: Fri Sep 27, 2002 2:22 pm
by AvengerX
-bump-

Re:Linking..

Posted: Mon Sep 30, 2002 12:43 am
by Pype.Clicker
this "4K incrementation" might be due to some default padding in your binary fileformat ... (very common with ELF, for instance)

Re:Linking..

Posted: Mon Sep 30, 2002 6:03 pm
by AvengerX
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..

Re:Linking..

Posted: Mon Sep 30, 2002 6:06 pm
by AvengerX
oh yeah, and how would i get it to boot with GRUB?

Re:Linking..

Posted: Tue Oct 01, 2002 1:56 am
by Pype.Clicker
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..

Posted: Tue Oct 01, 2002 5:23 pm
by AvengerX
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))