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
2
votes
1 answer

How to extract all of the sections in an obj file

I'm working on an X86_64 Ubuntu machine. I know that we can use the command to extract some sections from an obj file. Saying that I have an obj file, named main.o, now I can do things below: me@my-machine:~/tmp$ readelf -S main.o There are 13…
Yves
  • 11,597
  • 17
  • 83
  • 180
2
votes
0 answers

Integrating shared object in an application, ldd and readelf show different outputs

I am trying to integrate OpenCV into an application and facing some issues below. error while loading shared libraries: libopencv_imgproc.so.4.1: cannot open shared object file: No such file or directory However, when I check the output of ldd and…
pree
  • 2,297
  • 6
  • 37
  • 55
2
votes
2 answers

How to get the strings of shstrtab?

I am writing a simplified version of the Linux readelf command. I want to print section information, so I need the names of the sections. In the Elf64_Shdr struct, the sh_name variable only points me to an index in the shstrtab. But this does not…
Alexander Grass
  • 384
  • 2
  • 11
2
votes
2 answers

how to use GDB to debug loader/linker issue

I'm debugging a particularly weird issue that occurs before my program starts, ie. this happens at load time before code starts executing at the "_start" symbol. And yes I am modifying the ELF manually. There are no indications of a bad ELF format…
brookbot
  • 398
  • 1
  • 3
  • 11
2
votes
1 answer

Disagreement of tools for analyzing .bss section size of ELF file

While analyzing the .bss section of a C++ program compiled as ELF file for the ARM platform, I came across several ways to determine the size. The four ways I tested are also mentioned in the question Tool to analyze size of ELF sections and…
koalo
  • 2,113
  • 20
  • 31
2
votes
2 answers

Extract Structure definitions from executable

I need to extract structure definitions from an executable. How can I do that? I read we can do it using ELF, but not sure how to do this. Any help here?
Anup Buchke
  • 5,210
  • 5
  • 22
  • 38
2
votes
1 answer

VirtualAddress, LoadAddress, and PhysicalAddress in ELF file?

According to the ld manual on Output Section Description: section [address] [(type)] : [AT(lma)] [ALIGN(section_align) | ALIGN_WITH_INPUT] [SUBALIGN(subsection_align)] [constraint] { output-section-command …
smwikipedia
  • 61,609
  • 92
  • 309
  • 482
2
votes
1 answer

Readelf finding absolute address

I have a C programme which has one global and one local variable. My question is on the readelf. Following are my questions; 1. When i take the address dump using "readelf --symbols", i get an address for my global variable which is same as that of…
Franc
  • 319
  • 9
  • 28
2
votes
1 answer

ELF modify section flags

I compiled a C code using gcc and when I check the sections of the ELF using readelf I can see that the flags for .data section are set to WA (Writable and Allocatable). Is it possible to modify these flags? Can I make this section executable? I am…
Neon Flash
  • 3,113
  • 12
  • 58
  • 96
2
votes
1 answer

readelf error: not an elf file, wrong magic bytes at the start

I am trying to learn and use Elfreader by compiling a simple hello world program to a elf file as- gcc -o test test.c The file compiles correctly and runs perfect. But when I try to run ReadElf on it by readelf -h test it returns readelf: Error:…
Steve H
  • 461
  • 2
  • 10
  • 18
1
vote
0 answers

Simple struct increasing size of C++ Android binary

Why does adding the below struct to my public header cause my android binary size (libMyLibrary.so) to increase by 4KB? #define EXPORT __attribute__((visibility("default"))) struct EXPORT ITest { inline static const std::string TestString =…
rstr1112
  • 308
  • 4
  • 13
1
vote
0 answers

Addresses of pointers in C

I made this simple C program and compiled it without ASLR #include #include int a = 10; int b = 20; int main(int argc, char *argv[]) { printf("%lx\n",&a); printf("%lx\n",&b); return 0; } Every time I execute…
linux
  • 11
  • 2
1
vote
1 answer

Objdump to tell if binary was built on Redhat or Suse

Is there a switch in objdump or readelf which can tell if an ELF binary was built on Redhat or SUSE? I only have binary and no source code. Is there any other way (like strings command or nm) that could I could use if objdump/readelf isn't useful.
Rajat
  • 467
  • 1
  • 5
  • 15
1
vote
1 answer

Duplicate section VMAs of 0 in default linker script

arm-none-eabi-gcc's default linker script defines several sections with VMA of 0. Most of these contain debug information: /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 :…
AJM
  • 1,317
  • 2
  • 15
  • 30
1
vote
1 answer

How can I demangle or look inside readelf .symtable names?

I only have access to an object file for my assignment. When I disassemble the file I can read most of the assembly, but I'm having some trouble with a few calls. A call will mention some mangled names like: callq 0x147 _ZNSirsERi-0x4 So…
Troutt025
  • 55
  • 4