Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7866045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:16:23+00:00 2026-06-03T00:16:23+00:00

currently I’m writing little program that reads elf file header and prints some information

  • 0

currently I’m writing little program that reads elf file header and prints some information

I have an unsigned char pointer called buf which points to the location where elf file is located in memory(I used mmap to map it to memory), then I typecast it to a proper elf header pointer

Elf32_Ehdr *ehdr = (Elf32_Ehdr *)buf;

After this I want to get an address of the program header table, I do it like this

Elf32_Phdr *ptbl = (Elf32_Phdr *) (buf + ehdr->e_phoff)

As I noticed the value of ptbl pointer doesn’t change and when I try to print the value of the e_phoff member like this

fprintf( stdout , "Offset of program headers : %d\n", ehdr->e_phoff);

I get zero
Same stuff happens when I try to print number of program headers and number of section headers – always get zero
If I use linux readelf, it prints proper values
Does anyone experienced the same problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:16:24+00:00Added an answer on June 3, 2026 at 12:16 am

    When parsing an ELF object, you would need to keep in mind that:

    1. The size, file alignment and internal layout for in-file structures (such as the ELF Executable Header) depends on the ELF object’s word size.
    2. The endianness of the ELF object could differ from the ‘native’ endianness of the program reading the object.
    3. ELF objects containing a large number of sections or program segments may use an alternate “extended numbering” scheme.

    Rather than handle these cases by hand, it may be easier to use an implementation of the ELF(3) access API to parse the ELF object (see: BSD libelf, or GNU libelf).

    The tutorial “libelf by Example” contains a readable introduction to the ELF(3) API.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have alot of information that are in several different divs. I want
Currently I have a class that looks like this: public class MyClass : IMyClass
Currently, I have a log file of messages in one table in a MySQL
Currently i am working on 1 site, its requirement is that, i have to
Currently I have this code in .htaccess file to create a fake directory e.g.
Currently the HashSet<T> constructor that allows you to define your equality comparison yourself is
Currently I have a DetailsView attached to a GridView. When you select an item
Currently, I have something like: public partial class Form1 : Form { delegate void
Currently, I have: <html> <div class=yes1><span><img src=img></span></div> </html> <script> var x = ='yes1' var
currently I'm developing an app for WP7 but came across a little problem with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.