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
3 answers

How set set entry point in a elf target using ld script

I want to specify the entry point to my ELF file using the linker script. I already defined some sections in my ELF, so want to set an entry point also withit. Can anyone tell me how to do it?
vimal prathap
  • 411
  • 7
  • 17
1
vote
2 answers

Why are these specific relocations supported in ARM Linux ELF module loader?

I'm referring to linux/arch/arm/kernel/module.c. It seems to be an arbitrary subset of ARM ELF relocations. The manual lists about 130 types of relocations. Most of which are "static" (why is the module loader dealing with static relocations instead…
Yifan
  • 4,867
  • 5
  • 25
  • 24
1
vote
1 answer

ELF symbol visibility

Lets say I define an api (sym1) in file spec_a.h There is an implementation of this api in lib_imp1.so. I can have an application that dlopen's this shared library, dlsym() sym1 and invoke it. Is it possible for the application to dlopen() some…
Arjun
  • 31
  • 2
1
vote
1 answer

Printing the symbol table from elf file

I am trying to print the symbol table from an elf file. I got the offsets of sections .symtab and .strtab ( I crosschecked with readelf). but the program is giving segmentation fault. Here is the code in question: printf("\n\nSymbol…
Shyam Kadam
  • 124
  • 1
  • 2
  • 17
1
vote
1 answer

gcc error wrong ELF class: ELFCLASS64, despite haveing -m64 flag

I have been trying to build a library in solaris using gcc, and keep on hitting wrong ELF class: ELFCLASS64 error. I have googled and found out this is due to trying to link with a 32 bit file which compiling as a 64 bit library. But I have made…
vibz
  • 157
  • 1
  • 12
1
vote
1 answer

Understanding Red/System compilation optimizations compared to GCC

While reading the Red site, I came across a statement stating that compiling an hello world Red/System program creates.. "...a 162 bytes ELF binary, while a similar C code would produce a 5-6KB binary using Gcc" That's amazing. Can someone…
RAbraham
  • 5,956
  • 8
  • 45
  • 80
1
vote
1 answer

Locating and Editing Dynamic Symbol Table of Loaded Program?

My goal is explained in this question HERE Is it possible to locate the address of a symbol's entry in the dynamic symbol table loaded into a program? If we can locate it, can we edit it somehow? For example if the app made the call to a function…
Usman.3D
  • 1,791
  • 3
  • 16
  • 27
1
vote
1 answer

Loading a non-relocatable, static ELF binary in userspace

I'm trying to write a basic userspace ELF loader that should be able to load statically linked (not dynamically linked) non-relocatable binaries (i.e. not built with -pie, -fPIE and so on). It should work on x86 CPU's for now. I've followed the code…
Thomas
  • 3,321
  • 1
  • 21
  • 44
1
vote
0 answers

How to change size of the segment .text for file ELF ARM EABI?

I have ELF ARM EABI file without sources. It binary .so file. How to expand size of the segment .text of the file? I know this break code in this binary, but it is not a problem now.
Enyby
  • 4,162
  • 2
  • 33
  • 42
1
vote
0 answers

How do absolute paths get into the `NEEDED` portion of the dynamic section of an executable?

I have a number of executables which link against a single lib path. For instance, the executable foo links against (say) libboost_system.so and libfoo.so, the latter of which I build myself. I place third party libraries in a variable LDLIBS, and…
user14717
  • 4,757
  • 2
  • 44
  • 68
1
vote
0 answers

Building elf within Eclipse within Windows

I'm having trouble building an Elf file within Eclipse within Windows. It seems that everytime I build, a PE / portable executable for windows is created. I've gone into the Binary Parser section and checked Elf Parser while making sure that…
BSchlinker
  • 3,401
  • 11
  • 51
  • 82
1
vote
1 answer

Different results with cut and dd on binary files

My Environment: CentOS 6.5 I need to extract some part of the ELF file. When I use dd command as follows, I have no problem: $dd if=a.out of=a.cut1 bs=1 skip=16 On the other hand, when I use cut command as follows, the created file has much…
sevenOfNine
  • 1,509
  • 16
  • 37
1
vote
1 answer

Segmentation fault .data

I have a little question about "segmentation-fault" issue, but I can find any answer. I can deactivate the stack protection at the gcc compilation, with options [-fno-stack-protector] -z execstack: GNU_STACK 0x0000000000000000 **RWE** …
JohnCage
  • 37
  • 5
1
vote
1 answer

Possible to add executable section/segment to ELF binary?

It's easy to add an empty section with objcopy --add-section. However, I'd like the added section can be loaded as normal .text section and executable. Which means need modify segment header. Any suggestion?
Ivellios
  • 100
  • 7
1
vote
2 answers

GCC 3.4.3/Cygwin - slowness

I have a GCC 3.4.3 toolchain built for ARM (arm-elf) here in my Windows 7 (64bits) setup. We use this to build our software product to a specific hardware. Recently, we have been experiencing some problems with this particular toolchain. First, when…