0

Hi all,
I'm learning GAS assmbler, and I've written the following test program:

.code32

.section .data
    values:
    .int 1,2,3,4,5,6,7,8,9
    output:
    .asciz "current value %d"

.section .text
    .globl _start
    _start:
    movl $10, %edi
    loop:
    movl values(,%edi,4),%eax
    pushl %eax
    pushl $output
    call printf
    addl $8, %esp
    dec %edi
    jnz loop
    pushl $0
    call exit

Since I'm on x64, but the code is for 32bit asm, I've assembled it using this command:
as --32 -o test.o test.asm
This command seems to produce a valid obj file.
The problem is that I'm not able to link this file to produce a valid elf32...
I'm using this command:
ld -dynamic-linker /lib/ld-linker.so.2 -lc -o stampa stampa.o -melf_i386
but it says that /usr/lib64/libc.so is not compatible with -lc

How should I link my test program ?? Thank you very much!

2
Contributors
1
Reply
16
Views
3 Years
Discussion Span
Last Post by GunnerInc
0

You need to install the 32 bit libraries:
ia32-libs
or
ia32-libs-multiarch
With your package manager or:

sudo apt-get install ia32-libs

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.