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

How does AI transform chaos engineering from an experiment into a critical capability? Learn how to effectively operationalize the chaos.

Data quality isn't just a technical issue: It impacts an organization's compliance, operational efficiency, and customer satisfaction.

Are you a front-end or full-stack developer frustrated by front-end distractions? Learn to move forward with tooling and clear boundaries.

Developer Experience: Demand to support engineering teams has risen, and there is a shift from traditional DevOps to workflow improvements.

Trending

  • Integrating Cursor and LLM for BDD Testing With Playwright MCP (Model Context Protocol)
  • Edge AI: TensorFlow Lite vs. ONNX Runtime vs. PyTorch Mobile
  • The Synergy of Security and Development: Integrating Threat Models With DevOps
  • How I Supercharged My GenAI App and Saved My Sanity

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
30.1K 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

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
  • [email protected]

Let's be friends: