You are not logged in.

#1 2013-11-17 13:06:06

hackyoung
Member
Registered: 2013-03-30
Posts: 6

Accessing a corrupted shared library

I wrote some assemble code to select the maximum from a set of number, save as select_maximum.s
assembled it with as select_maximum.s -o select_maximum.o and linked with ld -dynamic-linked /lib/ld-linux.so.2 -lc -o select_maximum select_maximum.o
It all went nice, no error reported. but when I hit the directive ./select_maximum to run the program, the bash showed me the following words
-bash: ./select_maximum: Accessing a corrupted shared library

I had no idea of this and googled it but nothing I got, I need some tips

the source code:

/* select_maximum.s
* to find the max number in a set of number
*/
.code32
.section .data
input:
    .int 32, 34, 23, 34, 45, 64, 23, 54, 2
hint:
    .asciz "the max number is %d \n"

.section .text
.globl _start
_start:
    nop
    movl $1, %edi
    mov input, %ebx
loop:
    movl input(, %edi, 4), %eax
    cmp %eax, %ebx
    cmova %eax, %ebx
    inc %edi
    cmp $10, %edi
    jne loop
    pushl %ebx
    pushl $hint
    call printf
    addl $8, %esp
    pushl $0
    call exit

Last edited by hackyoung (2013-11-18 01:18:11)

Offline

#2 2013-11-17 15:01:59

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Accessing a corrupted shared library

Moving from Arch Discussion to Programming & Scripting.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#3 2013-11-18 00:27:33

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: Accessing a corrupted shared library

Offline

#4 2013-11-18 01:12:32

hackyoung
Member
Registered: 2013-03-30
Posts: 6

Re: Accessing a corrupted shared library

I've tried it, but it still did not work. I got a segment error

Offline

#5 2013-11-18 03:22:27

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,156

Re: Accessing a corrupted shared library

This isn't homework, is it?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#6 2013-11-18 04:35:01

hackyoung
Member
Registered: 2013-03-30
Posts: 6

Re: Accessing a corrupted shared library

it isn't but my own homework. I am learning at&t assemble language
I did something like
ls -l /lib/ld-linux.so.1
bash told me:
lrwxrwxrwx 1 root root 22 Nov  9 22:55 /lib/ld-linux.so.2 -> ../lib32/ld-linux.so.2
but I could not find the file /lib32/ld-linux.so.2 even there is no lib32 derictory
what does this mean?

cfr wrote:

This isn't homework, is it?

Offline

#7 2013-11-18 17:06:52

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: Accessing a corrupted shared library

/usr/lib32/ld-linux.so.2 belongs to lib32-glibc. That's why I posted the link that I did. You're on 64 bit Arch, correct? I believe that your error is coming from trying to link to the the 32 bit glibc instead of the 64 bit one.

Offline

Board footer

Powered by FluxBB