DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Trending

  • How Large Tech Companies Architect Resilient Systems for Millions of Users
  • Designing for Sustainability: The Rise of Green Software
  • Navigating Double and Triple Extortion Tactics
  • Unlocking the Potential of Apache Iceberg: A Comprehensive Analysis

Converting a Raw Binary File Into an ELF/Dwarf File

Need to convert your binary file into an ELF or Dwarf file to help with debugging and loading? Here are the simple steps to make it happen.

By 
Erich Styger user avatar
Erich Styger
·
Jan. 30, 18 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
29.9K Views

Join the DZone community and get the full member experience.

Join For Free

Binary files are just a binary blob without debug information. Most debug tools and flashers are able to deal (raw) binary (see S-Record, Intel Hex, and Binary Files). But GDB and/or the P&E GDB server really needs an ELF/Dwarf file, which usually has all the debug information in it. This is a problem if all that I have is a binary file.

This post is about transforming a raw binary (.bin) file into an ELF/Dwarf file and adding a header to it:

Added Elf Header to Raw Binary File

Added ELF header to the raw binary file

I can make an ELF file out of a bin (raw binary) file with the GNU ‘objcopy‘ command like this:

arm-none-eabi-objcopy.exe --input-target=binary --output-target=elf32-little myApp.bin myApp.bin.elf


‘myApp.bin’ is the application binary file, and it adds an ELF/Dwarf header file to the output file myApp.bin.elf. I can inspect/verify that with the ‘readelf’ GNU program:

arm-none-eabi-readelf.exe -a myApp.bin.elf


Which gives, for example:

ELF Header:
 Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
 Class: ELF32
 Data: 2's complement, little endian
 Version: 1 (current)
 OS/ABI: UNIX - System V
 ABI Version: 0
 Type: REL (Relocatable file)
 Machine: None
 Version: 0x1
 Entry point address: 0x0
 Start of program headers: 0 (bytes into file)
 Start of section headers: 26956 (bytes into file)
 Flags: 0x0
 Size of this header: 52 (bytes)
 Size of program headers: 0 (bytes)
 Number of program headers: 0
 Size of section headers: 40 (bytes)
 Number of section headers: 5
 Section header string table index: 2

Section Headers:
 [Nr] Name Type Addr Off Size ES Flg Lk Inf Al
 [ 0] NULL 00000000 000000 000000 00 0 0 0
 [ 1] .data PROGBITS 00000000 000034 0068f4 00 WA 0 0 1
 [ 2] .shstrtab STRTAB 00000000 006928 000021 00 0 0 1
 [ 3] .symtab SYMTAB 00000000 006a14 000050 10 4 2 4
 [ 4] .strtab STRTAB 00000000 006a64 000058 00 0 0 1
Key to Flags:
 W (write), A (alloc), X (execute), M (merge), S (strings)
 I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
 O (extra OS processing required) o (OS specific), p (processor specific)


Now I can use that file like any normal ELF/Dwarf file (of course, it does not have debug information in it), e.g. see Using Eclipse to Program Binary Files to an Embedded Target.

That’s all!

Happy Binaring!

Links

  • S-Record, Intel Hex, and Binary Files
  • Using Eclipse to Program Binary Files to an Embedded Target
  • MCUXpresso IDE: S-Record, Intel Hex, and Binary Files
  • Converting S19 Files into Binary Files with GNU objcopy
  • Binary (and S19) Files for the mbed Bootloader with Eclipse and GNU ARM Eclipse Plugins
Binary file

Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!