Mail Archives: djgpp/2005/08/04/06:30:25
Matthew Petricone <strstream AT gmail DOT com> wrote:
> I use ld-elf because I have to link the c code with asm compiled with
> nasm.
I don't agree that this would be sufficient reason. NASM can easily
be told to output files which the normal DJGPP linker can handle.
> Plus i like to use elf since Grub seems to be easier to use with
> binaries in ELF format.
I somewhat doubt that --- the binaries that Grub is best trained to
work with are neither ELF nor COFF: they're raw binary images
prepended by a PC-style boot sektor, also known as "Linux kernels".
> The funny thing is, I use the divide operator in other files, and
> they don't throw me the error upon linking.
The divdi3 and moddi3 are the intrinsic functions used by GCC to
implement 64-bit division on platforms like ours, that don't have
64-bit CPUs. They're in a library called libgcc.a. If you want to
use them, you have to link to that library. A linker run coordinated
by gcc.exe does that for you automatically. If you run ld yourself,
this is one of the things you have to know about. That's why in case
of doubt, you should always construct your own invocation of ld by
looking what 'gcc -v' prints out as the command for a normal link, and
modifying that, rather than starting from scratch.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -