Re: Issue linking 32-bit GAS assembly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Wed, Oct 17, 2018 at 10:59:07PM +0200, Andy Pieters wrote:
> On Wed, Oct 17, 2018 at 9:37 PM Dutch Ingraham <stoa@xxxxxx> wrote:
> >
> > Hi all:
> >
> > I'm having a problem linking 32-bit GAS assembly code that references external
> > C libraries on an up-to-date 64-bit Arch installation.
> >
> > I have enabled the 32-bit repositories and installed the multilib-devel group
> > and lib32-glibc. I have updated the library cache with ldconfig and rebooted.
> >
> > The command to assemble is: <as --32 -o filename.o filename.s>.  Assembly
> > succeeds.
> >
> > However, when linking using the command
> > <ld -melf_i386 --dynamic-linker /lib32/ld-linux.so.2 -lc -o filename filename.o>
> >
> > the command fails with:
> >         ld: skipping incompatible /usr/lib/libc.so when searching for -lc
> >         ld: skipping incompatible /usr/lib/libc.a when searching for -lc
> >         ld: cannot find -lc
> >
> > Note this linker command (or a hierarchy-appropriate one) seems standard, and
> > succeeds on a 64-bit Debian OS.
> >
> > There is a fairly recent Forum question (but pre-dating the discontinuance of
> > i686 support) regarding the same issue at
> > https://bbs.archlinux.org/viewtopic.php?id=229235 which indicates the command
> > should be:
> >
> > <ld -melf_i386 -shared -L /usr/lib32 -dynamic-linker /lib/ld-linux.so.2 -o \
> > filename filename.o -lc>
> >
> > This command succeeds, insofar as the linker returns an exit code of 0. However,
> > running the program (and all other similar programs) fails with "Illegal
> > instruction (core dumped)." Assembling with debugging symbols and running a
> > backtrace didn't enlighten me.
> >
> > Note that changing /lib/ld-linux to /usr/lib32/ld-linux in the command immediately
> > above produces the same result, as confirmed by the output of <ldconfig -p>
> >
> > Anyone see something I've missed of have any suggestions?  Thanks.
> >
> >
> > -----------
> >
> > Here is some simple code to test with:
> >
> >
> > # paramtest2.s - Listing system environment variables
> > .section .data
> > output:
> >    .asciz "%s\n"
> > .section .text
> > .globl _start
> > _start:
> >    movl %esp, %ebp
> >    addl $12, %ebp
> > loop1:
> >    cmpl $0, (%ebp)
> >    je endit
> >    pushl (%ebp)
> >    pushl $output
> >    call printf
> >    addl $12, %esp
> >    addl $4, %ebp
> >    loop loop1
> > endit:
> >    pushl $0
> >    call exit
> 
> Silly question perhaps but does that file actually exist, /lib32/ld-linux.so.2?
> 
> I haven't set up 32 bit etc and that file doesn't exist on my machine,
> and I get the exact same errors as you.

No, but /usr/lib32/ld-linux.so.2 does, as a symlink to ld-2.28.so.  As
noted, I've tried that as well, with the same results.



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux