ELF Options

Parent Previous Next

Purpose

This document describes advanced elf options in winIDEA.

ELF specification

Executable and Linking Format (ELF) file (see http://en.wikipedia.org/wiki/Executable_and_Linkable_Format ) is a standard format for executable, object and library files.

Each elf file contains:

Program header  table

Section header table

Data referred by two header tables

Program header table

Program header table with its segments represents Execution View of the program. It tells the system loader (winIDEA or OS) how create the image in the CPU memory space. Its segments also contain actual data to be loaded.

Section header table

Section header table with its sections represents Linking View of the program. Table contains list of sections which contain: debug info, symbol table, relocation information… These tables are typically generated by the compiler for each source file in the program and consequently processed by the linker to create merged section header table + actual sections in the final executable file.

Sample ELF file


================

PROGRAM HEADERS

================

NUM TYPE OFFSET  SIZE  VIRTADDR  PHYADDR  MEMSIZE   FLAGS  ALIGNMNT

  0 LOAD    120  B600         0        0     B600       5         1

  1 LOAD   B720  4B18      B600        0     4B18       7         1

=========

SECTIONS

=========

NUM NAME          TYPE       FLAGS OFFSET SIZE      ADDR ALI RECS LINK  NFO

  1 .text         PROGBITS    AX0     120 B58C         0   8    0    0    0

  2 .sdata2       PROGBITS    AX0    B6AC   74      B58C   4    0    0    0

  4 .data         PROGBITS   WA 0   10238   FC     10118   4    0    0    0

  5 .sdata        PROGBITS   WA 0   10334   54     10214   4    0    0    0

  6 .sbss         NOBITS     WA 0   10388   80  40000150   4    0    0    0

  7 .bss          NOBITS     WA 0   10388  30C  400001D0   8    0    0    0

  8 .ctors        PROGBITS   WA 0   10388   14  400004DC   4    0    0    0

  9 .dtors        PROGBITS   WA 0   1039C    8  400004F0   4    0    0    0

 10 .debug_line   PROGBITS      0   103A4  D50         0   1    0    0    0

 11 .debug_info   PROGBITS      0   110F4 354C         0   1    0    0    0

 12 .debug_frame  PROGBITS      0   14640  800         0   1    0    0    0

 13 .frame_info   PROGBITS   WA 0   14E40  340     10268   4    0    0    0

 14 .debug_abbrev PROGBITS      0   15180  6FC         0   1    0    0    0

 18 .symtab       SYMTAB        0   15904 3740         0   4   16   13  1FC

 19 .strtab       STRTAB        0   19044 37E4         0   1    0    0    0

 20 .shstrtab     STRTAB        0   1C828   D0         0   1    0    0    0


Each Program header table entry contain an offset, size and address of the code/data to be loaded into the memory. Address can be either physical or virtual (OS specific).

Sections represent linking view of the program. Each section has a name which informs the loader about its content. For example:

.text contains program code

.data contains program data (global initialized variables)

.bss contain program data (global uninitialized variables – zeroed by startup code)

.ctors contains array of function pointers that point to global variables constructors (C++)

.dtors contains array of function pointers that point to global variables destructors (C++)

.debug_* sections contain debug info about the program. They contain

.debug_info containes list of all functions, variables, types and its locations

.debug_frame contains  information for call stack reconstruction

.debug_line contains list of all lines (address, line number, source file) of the program

.symtab contains symbol table which is a list of names + addresses. They are typically used in the linking process to resolve external symbols not defined in the current object file

.strtab contains list of strings used by other sections

Note that there can be many other sections that compiler package can generate.

winIDEA advanced ELF options

winIDEA uses several options when loading ELF files. They can be set for each individual ELF file by clicking on the Advanced… button in Download File Properties dialog box.


Load Symbol Table Items

Select None, Global or Global and Local to filter which symbols will be loaded. Typically complete debug info should be already loaded from the .debug_info sections of the elf file, however in some cases compilers choose to write certain symbols only into the symbol table (code labels from the assembler files). You can also choose to load symbols, to see code and data labels from standard or third party libraries which usually do not contain any debug info.

Load Zero-sized Segments

When checked, winIDEA will also load all segments from program headers table that have SIZE set to 0, but MEMSIZE != 0. Memory will be filled with zeros.

Load debug sections

Load .debug_* sections. If  not checked high level debugging for this ELF file will not be possible. Useful for ELF files that are already debugged.


Reverse Bit-fields order

Check if bit fields are not shown correctly.

Dump ELF Headers

Each time elf file is loaded winIDEA will also create a text file containing a dump of ELF file headers. If the name of the download file is sample.elf winIDEA will create $sample.elf.header.txt in the same folder. This options can be used when writing/debugging linker command files.

Load Code from

This options is provided due to differences between compiler packages. User can choose to load code from

Program Headers - Physical: data will be loaded from program header table using physical addresses

Program Headers - Virtual: data will be loaded from program header table using virtual addresses

Sections: winIDEA will load data from PROGBITS sections with flags set to A(llocated). See example above

Call Stack generation

Determines how call stack is generated.

Automatic: if .debug_frame is present in ELF file than this data is used to generate call stack, otherwise winIDEA will either use EABI compliant  (for some CPU families - PPC) or function prolog simulation.

using .debug_frame: force using of .debug_frame sections

EABI compliant: when EABI standard specifies layout of the call stack

Simulated: winIDEA will analyze function prologues.

Merge types

Types with the equal name in global namespace will be treated as same type through different compile units.

GCC ARM double format

Select format for “double” data types. Used only for GCC compiler

Remove optimized lines

This option will remove lines from debug info for optimized functions.

Insert Inlined functions

When set winIDEA will also load all instances of  inlined functions.

Load only "beginning of the statement" lines

Only lines marked with “beginning of the statement” are loaded. This will reduce number of lines and make stepping through code easier in some cases.