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

  • Home
  • SEARCH
  • 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 6778353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:15:24+00:00 2026-05-26T16:15:24+00:00

I’m dynamically loading some Linux libraries in C. I can get the start addresses

  • 0

I’m dynamically loading some Linux libraries in C.
I can get the start addresses of the libraries using the

dlinfo

(see 1).

I can’t find any information to get the size of a library, however.

The only thing that I’ve found is that one must read the

/proc/[pid]/maps

file and parse it for the relevant information (see 2).
Is there a more elegant method?

  • 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-05-26T16:15:24+00:00Added an answer on May 26, 2026 at 4:15 pm

    (This answer is LINUX/GLIBC specific)

    According to http://s.eresi-project.org/inc/articles/elf-rtld.txt

    there are link_map *map; map->l_map_start & map->l_map_end

        /* 
            ** Start and finish of memory map for this object.  
        ** l_map_start need not be the same as l_addr.  
        */
        ElfW(Addr) l_map_start, l_map_end;
    

    It is a bit not exact, as said here http://www.cygwin.com/ml/libc-hacker/2007-06/msg00014.html
    = some libraries are not continous in memory; the letter linked has some examples… e.g. this is the very internal (to rtld) function to detect is the given address inside lib’s address space or not, based on link_map and direct working with ELF segments:

    /* Return non-zero if ADDR lies within one of L's segments.  */
    int
    internal_function
    _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr)
    {
      int n = l->l_phnum;
      const ElfW(Addr) reladdr = addr - l->l_addr;
    
      while (--n >= 0)
        if (l->l_phdr[n].p_type == PT_LOAD
        && reladdr - l->l_phdr[n].p_vaddr >= 0
        && reladdr - l->l_phdr[n].p_vaddr < l->l_phdr[n].p_memsz)
          return 1;
      return 0;
    }
    

    And this function is the Other alternative, which is to find program headers/ or section headers of ELF loaded (there are some links to such information in link_map)

    And the easiest is to use some stat syscall with map->l_name – to read file size from the disk (inexact in detecting huge bss section).

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
Specifically, suppose I start with the string string =hello \'i am \' me And
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.