I like to know how programs work so to make it as bare bones as possible I fool around with assembly.
I just found out how to assemble code for x86_64 using wprintf function (found out wide chars are 32 bit). all I had to do was link to libc (-lc).
I'm trying to assemble code for 32-bit doing about the same thing but I stumbled quite a bit. Eventually I used gcc to do the linking ( and changed the _start: to main:). So then I did the linking myself using ld and included crt1.o crti.o and crtn.o. Then my program worked ( it wouldn't print out anything before ) So my question is, can I do something within my code to eliminate the need for these other 3 object files (and of course revert back to _start: instead of main:)?
test_lib.S
.section .data
locale:
.string ""
.align 4
printformat:
.long '%','l','c',0
.section .text
.global main
main:
pushl $locale
pushl $6
call setlocale
pushl $12414
pushl $printformat
call wprintf
pushl $2
call exit
and running the following
as --32 test_lib.S -o test_lib.o
ld -m elf_i386 -L/lib/ -L/usr/lib/ -I/lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o -lc /usr/lib/crtn.o test_lib.o -o test_lib
./test_lib
oh and the output is simply a japanese hiragana (ma)ま (notice there is no line break so it prints before the prompt)