Comments (11)
This is not only a false positive.
It seems that patchelf corrupt binary under powerpc64 :
$ ./ls: /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.21-powerpc64-unknown-linux-gnu/lib/ld64.so.1: bad ELF interpreter: Aucun fichier ou dossier de ce type
# patchelf to set the interpreter to a valid value
~/scratch/workspace/patchelf/src/patchelf --set-interpreter /gpfs/[.....]/nix/store/ng8p3bpwxlwp8dslv31dndkk4wrg79bp-bootstrap-tools/lib/ld-2.21.so ls
# retry execution
./ls
Processus arrêté
# valgrind trace
valgrind --tool=memcheck ./ls
==27375== Memcheck, a memory error detector
==27375== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==27375== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==27375== Command: ./ls
==27375==
Inconsistency detected by ld.so: rtld.c: 1141: dl_main: Assertion `_rtld_local._dl_rtld_map.l_libname' failed!
==27375==
==27375== HEAP SUMMARY:
from patchelf.
Anyone has seen something similar this before ?
from patchelf.
I add you a little over trace on this when using only native system tools
# copy ls in current directory
cp /bin/ls ./
# use it
./ls
# -> works with normal listing
# use patch elf to print interpreter
~/scratch/workspace/patchelf/src/patchelf --print-interpreter --debug ./ls
/lib64/ld64.so.1
# list again
./ls
# works
# now modify the interpreter with exactly the same value than before
~/scratch/workspace/patchelf/src/patchelf --set-interpreter /lib64/ld64.so.1 --debug ./ls
patching ELF file `ls'
replacing section `.interp' with size 17
this is an executable
using replaced section `.interp'
last replaced is 1
looking at section `.interp'
first reserved offset/addr is 0x214/0x10000214
first page is 0x10000000
needed space is 536
needed space is 592
needed pages is 1
changing alignment of program header 2 from 65536 to 4096
changing alignment of program header 3 from 65536 to 4096
clearing first 4060 bytes
rewriting section `.interp' from offset 0x1200 (size 17) to offset 0x238 (size 17)
rewriting symbol table section 5
# now let's try to use ls again
./ls
# crash : Process stopped
# let's try to use the buggy ls into valgrind
valgrind --tool=memcheck ./ls
==7562== Memcheck, a memory error detector
==7562== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==7562== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==7562== Command: ./ls
==7562==
==7562==
==7562== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==7562== Access not within mapped region at address 0x0
==7562== at 0x8082267C9C: dl_main (in /lib64/ld-2.12.so)
==7562== by 0x80822811F7: _dl_sysdep_start (in /lib64/ld-2.12.so)
==7562== by 0x8082265E43: _dl_start_final (in /lib64/ld-2.12.so)
==7562== by 0x808226612B: _dl_start (in /lib64/ld-2.12.so)
==7562== by 0x80822654EF: _start (in /lib64/ld-2.12.so)
==7562== If you believe this happened as a result of a stack
==7562== overflow in your program's main thread (unlikely but
==7562== possible), you can try to increase the size of the
==7562== main thread stack using the --main-stacksize= flag.
==7562== The main thread stack size used in this run was 10485760.
==7562==
from patchelf.
From the previous trace, it --set-interpreter seems to be broken for powerpc64.
from patchelf.
I see the code does try to be correct with endian issues, but has it ever been tested on a big-endian HW? There could be a bug in the handling (or introduced since last testing).
from patchelf.
From the previous trace,
Here you have :
The readelf output before patching
The readelf output after patching
and here is the diff between both.
from patchelf.
Notes in the project says it has been tested on powerpc 32 bits which is big endian. But I do'nt think any tests has been executed on powerpc64.
from patchelf.
I just did the same test than before but using 32-bits ELF binaries. It works perfectly on PPC 32 bits.
The problem is triggered only in PPC 64 bits.
from patchelf.
I found the issue.
Powerpc64 kernels can have a page size up to 65K.
This is the case here.
The Patchelf should use sysconf(_SC_PAGE_SIZE) when available to detect the kernel page size.
I'm going to make a patch for this.
from patchelf.
Patch provided with #54
from patchelf.
Solved with #54
from patchelf.
Related Issues (20)
- patchelf: cannot find section '.interp'. The input file is most likely statically linked
- Test regression in 0.18.0: repeated-updates.sh, replace-add-needed.sh HOT 5
- patchelf breaks dylibs from recent Firefox Nightly builds HOT 11
- repeated-updates.sh fails on mips64el HOT 1
- What versions support redhat6
- `patchelf --set-interpreter` and `patchelf --set-rpath` depend on the order (at least on i686-linux) HOT 3
- Allow --rename-dynamic-symbols to change the version tag.
- Regression in 0.18.0: --set-rpath creates broken header alignment HOT 3
- `patchefd --set-rpath ... nodejs` broken since ~0.17.2 (0.15.0 works) HOT 3
- when I use zsh plugins zsh-autosuggestions, it something wrong HOT 1
- Program header editing features HOT 5
- SEGV when ELF has a malformed .dynamic section
- Relocatable binaries not handled
- Patchelf 0.18.0 Build failure on s390x with "span : out of range error"
- build failed for NetBSD
- rename-dynamic-symbols produces unusable binary
- Need help for cross-compliling libc.so.6
- patchelf: cannot normalize PT_NOTE segment: non-contiguous SHT_NOTE sections HOT 1
- _arguments:463: command not found: dynamic HOT 6
- `replace-needed.sh` test fails on 32-bit arm
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from patchelf.