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
198
votes
4 answers

Determine direct shared object dependencies of a Linux binary?

How can I easily find out the direct shared object dependencies of a Linux binary in ELF format? I'm aware of the ldd tool, but that appears to output all dependencies of a binary, including the dependencies of any shared objects that binary is…
Free Wildebeest
  • 7,272
  • 8
  • 38
  • 42
186
votes
9 answers

CentOS 64 bit bad ELF interpreter

I have just installed CentOS 6 64bit version, I'm trying to install a 32-bit application on a 64-bit machine and got this error: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory How do I resolve this?
c11ada
  • 4,302
  • 15
  • 48
  • 62
170
votes
9 answers

"No such file or directory" error when executing a binary

I was installing a binary Linux application on Ubuntu 9.10 x86_64. The app shipped with an old version of gzip (1.2.4), that was compiled for a much older kernel: $ file gzip gzip: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),…
Lorin Hochstein
  • 57,372
  • 31
  • 105
  • 141
133
votes
4 answers

Can I change 'rpath' in an already compiled binary?

I have an old executable that's scheduled for the scrap heap, but it's not there yet. It relies on some libs that have been removed from my environment, but I have some stub libs someplace where it works fine. Id like to point this executable to…
Rich Homolka
  • 1,805
  • 2
  • 13
  • 13
130
votes
6 answers

How to install GCC piece by piece with GMP, MPFR, MPC, ELF, without shared libraries?

How do I install GCC (the GNU Compiler Collection) piece by piece, using the current version, using the correct versions of dependencies, not using a package manager (like yum, rpm, apt, dpkg), and not using shared libraries? Typical developers will…
joelparkerhenderson
  • 34,808
  • 19
  • 98
  • 119
127
votes
15 answers

bcrypt invalid elf header when running node app

I'm working on a nodejs project for school. I wasn't able to install bcrypt with npm so i installed bcrypt-nodejs and the project worked fine yesterday. But today, when I do a "node app" i have this error…
user2244469
  • 1,271
  • 2
  • 8
  • 5
114
votes
11 answers

How to disassemble one single function using objdump?

I've got a binary installed on my system, and would like to look at the disassembly of a given function. Preferrably using objdump, but other solutions would be acceptable as well. From this questions I've learned that I might be able to disassemble…
MvG
  • 57,380
  • 22
  • 148
  • 276
111
votes
7 answers

C/C++ with GCC: Statically add resource files to executable/library

Does anybody have an idea how to statically compile any resource file right into the executable or the shared library file using GCC? For example I'd like to add image files that never change (and if they do, I'd have to replace the file anyway) and…
Atmocreations
  • 9,923
  • 15
  • 67
  • 102
111
votes
6 answers

What is the difference between ELF files and bin files?

The final images produced by compliers contain both bin file and extended loader format ELf file ,what is the difference between the two , especially the utility of ELF file.
Manik Mahajan
  • 1,566
  • 2
  • 13
  • 19
102
votes
3 answers

What's the difference of section and segment in ELF file format

From wiki Executable and Linkable Format: The segments contain information that is necessary for runtime execution of the file, while sections contain important data for linking and relocation. Any byte in the entire file can be owned by at most…
tsing
  • 1,441
  • 2
  • 12
  • 15
101
votes
3 answers

How can I examine contents of a data section of an ELF file on Linux?

I've been using objdump to look at assembly code in Linux ELF binaries. Sometimes there is an indirect jump through a jump table that is stored in the rodata (read-only data) section. How to get objdump or any other tool to show me the contents of…
Norman Ramsey
  • 198,648
  • 61
  • 360
  • 533
87
votes
5 answers

What exactly does `-rdynamic` do and when exactly is it needed?

What exactly does -rdynamic (or --export-dynamic at the linker level) do and how does it relate to symbol visibility as defined by the -fvisibility* flags or visibility pragmas and __attribute__s? For --export-dynamic, ld(1) mentions: ... If you…
Petr Skocik
  • 58,047
  • 6
  • 95
  • 142
80
votes
5 answers

How to retrieve the GCC version used to compile a given ELF executable?

I'd like to retrieve the GCC version used to compile a given executable. I tried readelf but didn't get the information. Any thoughts?
Ilyes Gouta
  • 801
  • 1
  • 7
  • 3
73
votes
2 answers

Floating point exception ( SIGFPE ) on 'int main(){ return(0); }'

I am trying to build a simple C program for two different Linux environments. On one device the program runs fine, on the other device the program generates a floating point exception. The program does nothing but return 0 from main which leads me…
Chimera
  • 5,884
  • 7
  • 49
  • 81
67
votes
4 answers

arm gcc toolchain as arm-elf or arm-none-eabi, what is the difference?

When you build a gcc toolchain there is the possibility to build it as arm-elf or as arm-none-eabi, but what is the difference? I use the eabi today, but that is just since everyone else seem to do that... but since that is a really bad argument,…
Johan
  • 20,067
  • 28
  • 92
  • 110
1
2 3
99 100