c - What the usage of "--oformat=elf32-i386"? -



c - What the usage of "--oformat=elf32-i386"? -

i have confusion 2 command line options of gnu linker --- ld. before question, show backgrounds.

i reading richard blum's professional assembly language these days, , cpuid.s sample of assembly code book. book introduces 32-bit assembly programming, mine 64-bit os.

in order generate 32-bit output, in accord book's sample. uses next 2 command assembly , link code:

as --32 -o cpuid.o cpuid.s ld --oformat=elf32-i386 -o cpuid cpuid.o

however, @ sec step, ld fails "ld: i386 architecture of input file `cpuid2.o' incompatible i386:x86-64 output".

after google, find need utilize -melf_i386 option:

ld -melf_i386 -o cpuid cpuid.o

yeah, time link success, don't know why, in gnu's official documentation, says:

you can utilize `--oformat' alternative specify binary format output object

i uses 32-bit object file cpuid.o, , tell ld generate 32-bit output explicitly through --oformat=elf32-i386 optoin, think should no trouble. why must utilize -melf_i386 option? reasons of existing --oformat?

i tried googled anwser, failed, found 2 relevant links below, not answers question:

http://www.linuxquestions.org/questions/linux-software-2/relocatable-linking-on-x86-64-for-i386-872812/

building 32-bit app in 64-bit ubuntu

any help appreciated. thanks...

an output format not correspond architecture, though might case elf32-i386. others ihex or bin there no way ld take appropriate architecture emulation. that's why defaults 1 has been compiled for, seems x86-64 in case.

c assembly linker gnu

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -