• Like
Tag system
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Tag system


Tag system

Tag system

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On SlideShare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Using a tag system GAYET Thierry
  • 2. PLAN
    • Goal
    • ELF-file layout
    • Tagging process
    • Extracting a tag
    • Tools available
    • Links about
  • 3. Goal For an ELF make by the build system (buildroot + autotools) this is possible to customize its Sections (data or others) ; it can be easily integrated into the autotools template. It could be information about the build process such as the toolchain release, the datetime, and so on. It may be only an unique ID stored in a database for tracing the build specification The aim is to add a traceability for each build objects in order to know how a binary have been compile by/with (what toolchain kind/version :version of gcc, libc, … ).
  • 4. ELF-file layout Each ELF file is made up of one ELF header, followed by file data. The file data can include: Program header table, describing zero or more segments Section header table, describing zero or more sections Data referred to by entries in the program header table, or the section header table The segments contain information that is necessary for runtime execution of the file, while sections contain important data for linking and relocation. Each byte in the entire file is taken by no more than one section at a time, but there can be orphan bytes, which are not covered by a section. In the normal case of a Unix executable one or more sections are enclosed in one segment.
  • 5. Tagging process
    • Example for creating a temporally TAG file:
    • touch ./myTag
    • echo "SDK = " $(NOM_PROJET) $(VERSION_PROJET) - $(RELEASE_DATE) >> ./myTag
    • echo "TARGET = " $(TARGET_ID) >> ./myTag
    • echo "BUILT = " $(shell date +"%Y/%m/%d %H:%M:%S") on $(BUILD_HOST) $(BUILD_KIND) >> ./myTag
    •  This TAG can be easily updated according to our specifications.
    • Revove any previous MYTAG section from the ELF header of the file :
    • objcopy --remove-section MYTAG ./MyElfFileToModify
    • Adding a new section called MYTAG in the ELF file and update the ELF file with the previous tag created :
    • objcopy --add-section MYTAG=./myTag --set-section-flags MYTAG=contents ./MyElfFileToModify
    • Removing the temporally file:
    • rm -f ./myTag
  • 6. Extracting a tag (using the libELF)
    •  Example of source code available here :  http://www.nextinnovation.org/doku.php?id=search_elf_symbol&s[]=tag#source_code_searchsymc
  • 7. Build the extraction tool
    • Compilation:
    • gcc -g -Wall -I$LIB_ELF_PATH/include -c searchsym.c -o searchsym.o
    • Linking:
    • gcc -L$LIB_ELF_PATH/lib -lelf searchsym.o -o searchsym
  • 8. Tools available
    • Lot of tools exist for managing/extracting ELF formats :
    • Libelf
    • Objcopy
    • Objdump
    • Readelf
    • And many others...
  • 9. Links about
    • http://manpagesfr.free.fr/man/man5/elf.5.html
    • http://elftoolchain.sourceforge.net/for-review/libelf-by-example-20100111.pdf
    • http://developers.sun.com/solaris/articles/elf.html