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

Open source linker written in C

I am building a programming language that I want to cross compile onto OSX, Windows, and Linux natively (into Mach-O, PE, and ELF formats respectively). Are there any linkers, written in C/C++ that I could integrate with my compiler? Thanks
1
vote
2 answers

In ELF library filenames, how important are the major and minor versions with regards to compatibility?

I have a collection of binaries I installed on a Linux machine. They require the libgfortran library, but on execution display the following message: error while loading shared libraries: libgfortran.so.2: cannot open shared object file: No such…
Ajjajj
  • 67
  • 5
1
vote
1 answer

How to combine two or more relocatable ELF files into one relocatable ELF file using GNU ld?

I have two x86 assembly source files a.asm and b.asm (written in NASM syntax). a.asm and b.asm combined is an implementation of the function myfun(int a, int b) which returns a+1+b. But I put the codes into separate files. ; a.asm global…
PeopleMoutainPeopleSea
  • 1,492
  • 1
  • 15
  • 24
1
vote
2 answers

Error: expecting string instruction after `repz'

So basically I am trying to re-use some asm code disassembled from objdump on 32 bit Linux, ELF binary. In the disassembled file, I see this instruction: 8057a01: f3 c3 repz ret and when I try to re-use repz ret in my asm…
lllllllllllll
  • 8,519
  • 9
  • 45
  • 80
1
vote
1 answer

ELF File generation commands and options

I was reading about ELF files on the net and am stuck in understanding a standard command to generate an ELF file. Till now I have been running my code using > gcc test.c -o test.o .Thats it!! One article says: gcc -c test.c // will generate ELF…
RootPhoenix
  • 1,626
  • 1
  • 22
  • 40
1
vote
1 answer

Address space of a .bss section space in elf file

If I understand corretly, by creating a section of .bss type (as below code example) the write/read area of the .bss section is from section's offset in the file to N and in this case phdr.p_memsz gets incremented by N bytes and it's up to operating…
The Mask
  • 17,007
  • 37
  • 111
  • 185
1
vote
1 answer

Remote Proc fails to load FreeRTOS Elf

I am using this port of FreeRTOS and I am loading it onto the Cortex-M3 within an OMAP4430. This works fine using the remote proc framework and I am able to use RPMsg to communicate with it. Sometimes, however, rproc fails to load the elf and gives…
Henry
  • 13
  • 1
  • 5
1
vote
1 answer

ELF Header, are offset 06h and 14h duplicated?

I would like to know if these 2 headers have the same meaning nor why? From wikipedia : offset 06h : Set to 1 for the original version of ELF. offset 14h : Set to 1 for the original version of ELF. reference :…
Frederic Nault
  • 986
  • 9
  • 14
1
vote
1 answer

Is there any macro or pointer within ld.so which can give me address range of all the plt sections?

I am modifying the libc6 dynamic linker. For a given program which is run and all the shared libraries which are loaded with it I need the address range(start address + length) of all the respective .plt sections. Is there any macro or pointers…
abhi
  • 3,476
  • 5
  • 41
  • 58
1
vote
0 answers

QNX ELF File Format

I am trying to figure out the differences between ELF executables linked for QNX and Linux, respectively. Is the exact ELF executable format needed by QNX documented somewhere? Minimally, what sections, segments, entries, etc. do I need in an ELF…
distributed
  • 366
  • 4
  • 13
1
vote
1 answer

Doesn't PIC mean no relocations?

I'm building an ELF SO for bada on ARM using GCC. The compiler options include -fpic. Yet in the built file, when I do readelf -r, there's a whole lot of relocation records, of following…
Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
1
vote
1 answer

How to trace code using ARM ELF?

How to track code using ARM ELF? Which tools we have to use?
Coder
  • 1,661
  • 4
  • 27
  • 50
1
vote
1 answer

cross os build by converting static bulid into os specific binary

Is it possible to write code in C, then statically build it and make a binary out of it like an ELF/PE then remove its header and all unnecessary meta-data so to create a raw binary and at last be able to put this raw binary in any other kind of OS…
user3289857
1
vote
2 answers

Compare byte in unsigned char with hex, test if file is ELF file

I need to test if a file is a ELF file, to do this, i have to compare the first four bytes. The first bytes of the files begins with 0x7F 0x45 0x4C 0x46. I use fread(...) to read first four bytes out to an array. Printing the content of the array…
user265767
  • 559
  • 3
  • 12
  • 27
1
vote
2 answers

How to decode a debug_line section?

I'm trying to figure out how a DWARF 2 debug_line section is encoded. The standard paper (http://www.dwarfstd.org/doc/dwarf-2.0.0.pdf) isn't much helpful to me and I really don't understand how something like the following: .4byte .debug_line …
Marco A.
  • 43,032
  • 26
  • 132
  • 246
1 2 3
99
100