Questions tagged [elf]

ELF stands for Executable and Linkable Format, a file format for files containing machine code. Use this tag for questions about the ELF format itself, or for questions which are specifically about reading/writing ELF files.

The Executable and Linkable Format (ELF) standard describes a layout for files containing executable machine code. The format is non-proprietary, flexible, extensible and machine architecture-independent.

Most modern open-source operating systems (e.g., Linux) use ELF for their native executables. Notable exceptions are Windows (using PE/COFF) and macOS/iOS (using Mach-O).

Questions that should use the tag:

  • Questions about the ELF format itself, e.g. how certain fields should be used or what their intention is.
  • Questions about reading/parsing ELF files, e.g. via the C elf.h standard header or with the readelf program.
  • Question about writing/modifying ELF files, e.g. using tools like objcopy or strip.

Resources:


Related tags:

  • For questions about the readelf program, which is used for parsing and dumping most non-machine code sections of an ELF file.
  • For questions about the objcopy program, which allows changing section contents or adding sections to existing ELF files.
2307 questions
1
vote
1 answer

Linking against a versioned .so without SONAME

I have a closed-source library that comes in a file named libfoo.so.1.2.3.4. objdump -p shows it doesn't have SONAME but does have RPATH=/usr/local/lib. Is it a bad practice? Should I try to push the library authors to change the options? How am I…
nponeccop
  • 13,527
  • 1
  • 44
  • 106
1
vote
3 answers

Linux: update embedded resource from executable

I have an executable in which I embed a binary file resource using the objcopy method objcopy --input binary --output elf32-i386 --binary-architecture i386 data.txt data.o link to data.o and use extern char _binary_data_txt_start extern char…
shoosh
  • 76,898
  • 55
  • 205
  • 325
1
vote
1 answer

execute function from address in elf file

I have a simple c file that prints a message in main and do nothing else Compiled it using gcc to generate .out file.Use the elf parser to get the entry_address of start function and using this addressas function pointer i am trying to execute the…
user2251377
  • 31
  • 1
  • 4
1
vote
1 answer

relocation section header information in .elf file

My apology for my poor English, really having a hard time understanding what is the sh_info field contains for relocation section, following is what I get from the ELF document: It says sh_info : contains the section header index of the section to…
sthbuilder
  • 561
  • 1
  • 7
  • 22
1
vote
1 answer

Shared Library (.so) file on hard drive changes when user processed killed

This is in continuance to my previous question. hash of libgmp.so changes automatically I have developed a library and linked it to my process. It is required that my library should have same hash (from installation time), every time I link it with…
awatan
  • 1,182
  • 15
  • 33
1
vote
1 answer

Procedure Linkage Table and Call Relative

I am curious how programs like readelf, objdump and gdb know what to display next to callq instructions. Since the program has yet to run how do they know how far to 'fall through' the .plt? Do they guess based on the arguments passed to it? Or do…
Owen M
  • 13
  • 3
1
vote
1 answer

ELF files and additional symbols

I'm reading about ELF file format and I've noticed that a small hello world test program written in C++ contains some additional initialization in the _start symbol: 0000000000400770 <_start>: ... 40077f: 49 c7 c0 60 09 40 00 mov …
user1529891
1
vote
2 answers

objdump doesn't show size for ostream class

I have this code: #include int main() { std::cout << sizeof(std::cout) << std::endl; return 0; } Compile it with g++ -g main.cpp (it prints 272 on my OS) After that I execute objdump --dwarf=info a.out and see next debug info…
eXXXXXXXXXXX2
  • 1,540
  • 1
  • 18
  • 32
1
vote
1 answer

program headers and section headers in ELF files

This is a repeat of a question but I could not quickly find an answer to my question. That's why asking it. Some ELF files contain(executables or shared libs) program headers which explain segments. They contain a field called virtual address and…
agent.smith
  • 9,134
  • 9
  • 37
  • 49
1
vote
1 answer

Linking hard float to softfp bad performance

I'm writing c++ code to run on ARM cortex a9 CPU. My code links to a closed source 3rd party library which is compiled with soft-float. I'm running a cortex-a9 ARM cpu. I noticed that if I compile my code with gcc flag -mfloat-abi=softfp, it runs…
oferlivny
  • 300
  • 4
  • 15
1
vote
1 answer

Encoding jump targets - Computer Systems A programmer's perspective

I'm reading through the part about how jump instructions are encoded and I am confused about the highlighted line of text: . How is 0xf3 = decimal -13? Is this an error? I tried checking the errata but nothing there either.
Faheem
  • 1,423
  • 2
  • 13
  • 22
1
vote
0 answers

How is the value of p_offset in ELF32 program headers computed?

I want to apply some custom code transformations on ELF32 binaries. First I parse the ELF file, then I apply the transformation(s) and afterwards I put the ELF sections back together in a new output file. Before I even start implementing any…
Benny
  • 607
  • 7
  • 20
1
vote
1 answer

Objdump gives Segmentation Fault with -S option

I am trying to use objdump to display source as well as disassembly using the -S option. I am running objdump on cygwin. I built objdump for ARM on cygwin. Compiler for build was gcc. The elf file was built for ARM processor using Thumb2 instruction…
TSG
  • 877
  • 1
  • 6
  • 23
1
vote
0 answers

The field shstrndx in ELF header

What the value of the e_shstrndx field in elf mean? In my file its value is 4. How can I get the section headers names in the file using this constant?
Mickey
  • 480
  • 4
  • 13
1
vote
1 answer

inserting code into elf

I want to write code in assembly which puts itself in a given ELF. My code looks like: func_start: ; Getting file descriptor, and additional code here mov eax, 4; Write Sys_call mov ebx, [fileDesc] mov ecx, func_start mov edx, func_end -…
Mickey
  • 480
  • 4
  • 13