Skip to content

Commit 5faf453

Browse files
committed
Add documentation and test case for --print-os-abi and --set-os-abi
Signed-off-by: Dmitry Moskalchuk <[email protected]>
1 parent a37476d commit 5faf453

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

patchelf.1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ INTERPRETER.
3636
.IP --print-interpreter
3737
Prints the ELF interpreter of the executable.
3838

39+
.IP --print-os-abi
40+
Prints the OS ABI of the executable (EI_OSABI field of an ELF file).
41+
42+
.IP "--set-os-abi ABI"
43+
Changes the OS ABI of the executable (EI_OSABI field of an ELF file).
44+
The ABI parameter is pretty flexible. For example, you can specify it
45+
as a "Linux", "linux", or even "lInUx" - all those names will set EI_OSABI
46+
field of the ELF header to the value "3", which corresponds to Linux OS ABI.
47+
The same applies to other ABI names - System V, FreeBSD, Solaris, etc.
48+
3949
.IP --print-soname
4050
Prints DT_SONAME entry of .dynamic section.
4151
Raises an error if DT_SONAME doesn't exist.

tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ src_TESTS = \
3333
endianness.sh \
3434
contiguous-note-sections.sh \
3535
no-gnu-hash.sh \
36+
change-abi.sh \
3637
grow-file.sh \
3738
no-dynamic-section.sh \
3839
args-from-file.sh \

tests/change-abi.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#! /bin/sh -e
2+
3+
SCRATCH=scratch/$(basename $0 .sh)
4+
5+
rm -rf ${SCRATCH}
6+
mkdir -p ${SCRATCH}
7+
8+
cp simple-pie ${SCRATCH}/simple-pie
9+
10+
# Save the old OS ABI
11+
OLDABI=`../src/patchelf --print-os-abi ${SCRATCH}/simple-pie`
12+
# Ensure it's not empty
13+
test -n "$OLDABI"
14+
15+
# Change OS ABI and verify it has been changed
16+
{
17+
echo "System V"
18+
echo "HP-UX"
19+
echo "NetBSD"
20+
echo "Linux"
21+
echo "GNU Hurd"
22+
echo "Solaris"
23+
echo "AIX"
24+
echo "IRIX"
25+
echo "FreeBSD"
26+
echo "Tru64"
27+
echo "OpenBSD"
28+
echo "OpenVMS"
29+
} | {
30+
while IFS="\n" read ABI; do
31+
echo "Set OS ABI to '$ABI'..."
32+
../src/patchelf --set-os-abi "$ABI" ${SCRATCH}/simple-pie
33+
34+
echo "Check is OS ABI is '$ABI'..."
35+
NEWABI=`../src/patchelf --print-os-abi ${SCRATCH}/simple-pie`
36+
test "$NEWABI" = "$ABI"
37+
done
38+
}
39+
40+
# Reset OS ABI to the saved one
41+
../src/patchelf --set-os-abi "$OLDABI" ${SCRATCH}/simple-pie
42+
43+
# Verify we still can run the executable
44+
${SCRATCH}/simple-pie

0 commit comments

Comments
 (0)