pouët.net

assembly files linked with c files, djgpp

category: code [glöplog]
 
I'm having trouble linking my files under djgpp.

main.c:
Code: #include <stdio.h> extern int hello; int main(void) { printf("%d\n", hello); }


hello.s:
Code: .section .rodata .globl hello .align 4 hello: .int 23


compile like this:
Code: gcc main.c hello.s


Now this should compile no problem. It work on unix. When I try and compile the same thing under djgpp I get an undefined reference to hello when linking.

objdump hello.o shows hello in the symbol table. What's up with djgpp?
added on the 2013-06-10 03:34:19 by sigflup sigflup
Nevermind everybody I figured it out
added on the 2013-06-10 03:42:44 by sigflup sigflup
... you're suppose to put a _ before all your symbols
added on the 2013-06-10 03:46:49 by sigflup sigflup
...so nice to see people doing oldschool stuff :) Good for you, sigflup :)
Happy to see the Genesis attack on oldschool PCs! :)

Makes me want to revive my 386 code and start finally coding an oldschool demo too (have been saying this since ages :P). And then everybody ressurects the 286/386/486 scene =)
added on the 2013-06-10 11:41:21 by Optimus Optimus
Also note you might need to specify extern "C" if you're compiling C++
added on the 2013-06-10 12:05:22 by Gargaj Gargaj
It will NOT need an underscore if targeting ELF executables (ELF requires external symbols to have the same name). Keep it in mind if you are doing hand-made assembler and will be aiming for ELF files.
added on the 2013-06-10 13:04:18 by Jcl Jcl
there actually was a pc 64k for a 286 laptop running dos 3.8 (or something) at flashback thise weekend :)
added on the 2013-06-10 13:17:50 by wysiwtf wysiwtf
Quote:
there actually was a pc 64k for a 286 laptop running dos 3.8 (or something) at flashback thise weekend :)


Wow really? Long Live 286/386/486 scene!
added on the 2013-06-10 14:33:22 by Optimus Optimus
Quote:
there actually was a pc 64k for a 286 laptop running dos 3.8 (or something) at flashback thise weekend :)


Don't bogart the warez! Gimme dl link.
Jcl: sorry, I'm a bit confused - is it possible to run ELF exes on DOS?
elf on dos? weird idea. O_o theoretically you could. write a loader and bit of environment to setup. elf is still just a kinda container for code and data. is it?. :)
added on the 2013-06-10 17:56:34 by yumeji yumeji
With the appropriate DOS Extender, this could work. But, is it of any use ?
bitnaughty: not in any way I know of, however, if you are using djgpp, chances are you are trying to write portable code, and if you write the underscores manually, it won't work when using other compilers. Also, the same would apply to ELF object files, not just executables (which djgpp can use, and he might be using since he's using .rodata sections instead of the older .text sections which were used on COFF object files)
added on the 2013-06-10 19:52:53 by Jcl Jcl
Jcl: thanks
Where is the 286 flashback intro?
added on the 2013-06-19 16:28:07 by Optimus Optimus
well a video capture of it can be found here but there seems to be no binary so ive not added it to pouet db yet.
added on the 2013-06-19 16:33:18 by wysiwtf wysiwtf

login