Questions tagged [readelf]

readelf displays information about ELF object files

readelf displays information about Executable and Linkable Format object files. It performs a similar function to objdump but it goes into more detail and it exists independently of the BFD library, so if there is a bug in BFD then readelf will not be affected.

On Linux, two widely available implementations exist:

138 questions
5
votes
3 answers

Extracting only my function names from ELF binary

Im writing a script for extracting all the functions (written by user) in a binary. The following shell script extracts my function names as well as some library functions which start with __. readelf -s ./a.out | gawk ' { if ($4 == "FUNC" && $3…
Jeyaram
  • 9,158
  • 7
  • 41
  • 63
4
votes
2 answers

why /lib32/libc.so.6 has two "fopen" symbol in it?

nm -D /lib32/libc.so.6 | grep '\' 0005d0c0 T fopen 00109750 T fopen readelf -s /lib32/libc.so.6 | egrep '0005d0c0|00109750' 181: 0005d0c0 50 FUNC GLOBAL DEFAULT 12 fopen@@GLIBC_2.1 182: 00109750 136 FUNC GLOBAL DEFAULT 12…
camino
  • 10,085
  • 20
  • 64
  • 115
4
votes
2 answers

What does "readelf: Warning: Corrupt offset in range entry N" mean?

I am running readelf -w on my (C++) executable to examine some debug sections and it prints the following warnings a couple of times: $ readelf -w a.out ... readelf: Warning: Corrupt offset (0x00000028) in range entry 1 readelf: Warning: Corrupt…
andreee
  • 4,459
  • 22
  • 42
4
votes
2 answers

Is jumping over/removing `PHDR` program header in ELF file for executable OK? If so, why?

I was doing some hacking in the binary for this simple C++ program to understand program headers for ELF: int main(){ } compiled with: ❯ make g++ -O0 -fverbose-asm -no-pie -o main main.cpp I used readelf -l main to get the following: Elf file type…
OneRaynyDay
  • 3,658
  • 2
  • 23
  • 56
4
votes
0 answers

How to understand .bss section disassemble code?

Source C code: static int b; Corresponding .bss section disassemble code in object file: Disassembly of section .bss: 00000000 : 0: 00 00 add %al,(%eax) 2: 00 00 add %al,(%eax) Based on the…
Edee
  • 1,746
  • 2
  • 6
  • 14
4
votes
0 answers

How padding works in elf file

I know the relationship between the virtual address and the file offset in an ELF file VirtAddr = Offset + k * Allin and I know it is due to page dimension (0x1000 in a x86 architecture). First question: Which is the page dimension in a x64…
Alvin
  • 139
  • 6
4
votes
1 answer

Application shows up as DYN (Shared object file)

I have an application on my Ubuntu system, built with CMake, using add_executable predicate. It runs fine by itself, however, readelf shows it as DYN (Shared object file) which is usually applied to shared libraries: root@3cced4f9860d build# readelf…
ilya1725
  • 4,496
  • 7
  • 43
  • 68
4
votes
1 answer

What does version info in ldd -v mean?

Version information: /usr/lib/lapack/liblapack.so: libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.2.5) =>…
colinfang
  • 20,909
  • 19
  • 90
  • 173
4
votes
1 answer

Printf Symbol Resolution

I'm writing a little program which trace all the syscall and calls of a binary file (elf) using ptrace (singlestep, getregs, pick_text, opcodes comparison, etc). So far I've succeed to trace syscalls and simple calls like user defined functions. But…
Thibaud Auzou
  • 129
  • 10
4
votes
1 answer

Determining symbol addresses using binutils/readelf

I am working on a project where our verification test scripts need to locate symbol addresses within the build of software being tested. This might be used for setting breakpoints or reading static data from memory. What I am after is to create a…
Michael Bauer
  • 183
  • 4
  • 15
4
votes
1 answer

List all symbols usable by ld linker

I have a small static library compiled by (linux) gcc 4.8.2 with -fvisibility=hidden which is linked to a shared library (I have two versions, gcc one with C code and ifort one with Fortran code). The static library consists of some internal…
Peter Petrik
  • 9,701
  • 5
  • 41
  • 65
4
votes
1 answer

Understanding the relocation table output from readelf

For example, running the command: readelf -r /bin/ls | head -n 20 I get the following output: Relocation section '.rela.dyn' at offset 0x15b8 contains 7 entries: Offset Info Type Sym. Value Sym. Name +…
Fred Thomsen
  • 1,538
  • 2
  • 13
  • 15
3
votes
1 answer

Address of element within a structure from elf executable

Is it possible to obtain the address of an element within a structure from an ELF executable not compile for debug? Example, given the following code: typedef struct { int tokyo; int paris; int london; }cities; cities places; Both nm and…
Chris
  • 538
  • 8
  • 19
3
votes
1 answer

What are the meanings of columns shown by readelf, while inspecting Section Headers?

Can someone explain the meaning of these columns? I use readelf to read a ELF file and can't find any rellevant info (like for objdump for example) about Section Headers columns. For example what are 'ES', 'Lk' and 'Info' ? What are all available…
yo3hcv
  • 1,531
  • 2
  • 17
  • 27
3
votes
1 answer

readelf 'Align' column unit

I have the following simple "hello world" program: #include int main() { printf("Hello world.\n"); return 0; } I compile it as gcc -static -O0 -g -std=gnu11 -o test_helloworld test_helloworld.c -lpthread Now, I want check its…
xxks-kkk
  • 2,336
  • 3
  • 28
  • 48
1
2
3
9 10