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 8832819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:37:28+00:00 2026-06-14T08:37:28+00:00

As can be seen in the second answer for this question , it’s quite

  • 0

As can be seen in the second answer for this question , it’s quite simple to get a pointer to an specific section of a program from within itself, using the section’s name. With libelf, just open the program’s own file, loop over all sections (which are represented by Elf64_Shdr structs) in it, stop when the section name matches the one you want and use the pointer stored in the sh_addr element of the Elf64_Shdr struct. In this case, it’s very simple to get the wanted pointer because it is defined in the ELF executable file.

But, imagine you have a program that uses a dynamic library and you need to get a pointer to a section of that dynamic library. Since the addresses of its sections are defined in runtime, how is it possible to get pointers to sections of a dynamic library?

By the way, both the dynamic library and the main program itself have, each one, a section with the same name (which is the one I need to get a pointer to). So, in this case, is it possible that these two sections with the same name are stored adjacently in memory, so that I just need to get a pointer to the main file’s section (as I explained in the first paragraph) and add an offset to reach the dynamic library section?

  • 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-14T08:37:29+00:00Added an answer on June 14, 2026 at 8:37 am

    it’s quite simple to get a pointer to an specific section of a program from within itself

    Not necessarily. The section table is not actually needed at runtime, and can be completely stripped (only segments matter, not sections).

    Since the addresses of its sections are defined in runtime, how is it possible to get pointers to sections of a dynamic library?

    The library is not at all different from the main executable. The main difference is that the library is usually linked at address 0 (the main executable is not), and relocated by the runtime loader to some other constant offset.

    Once you know that offset, just add it to the section start (which you can find from readelf -S foo.so or from libelf), and voila: you’ve got the runtime address of the section.

    So how can you find the relocation for a given shared library?

    Inelegant solution (already suggested by Nick) is to parse /proc/self/maps.

    A better solution is to use (glibc-specific) dl_iterate_phdr. Documentation here. You’ll want to use dlpi_addr .

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

Sidebar

Related Questions

If you haven't seen my question yesterday, this is my second rails app. The
I've seen this asked in several ways but can't find an answer that works.
We have several areas where code like this can be seen public Map extractData(ResultSet
I have this table, which can be seen as a basic custom gantt chart:
The new Basecamp is doing it, as it can be seen in this link
Hello yeah I'm asking this question a second time, sorry about that but I
My answer to this question would be no. But my coworkers disagree. We're rebuilding
This question has been asked to death on stack overflow, and I've seen a
I'm editing a program called TF2idle that can be seen here: http://facepunch.com/showthread.php?t=1161862 I'm adding
Which files can be seen by any viewer (-not someone who has the password

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.