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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:30:04+00:00 2026-06-09T13:30:04+00:00

1). print function address directly: printf(strerror=%p, strerror_r=%p\n, strerror, strerror_r); strerror=0x8049ec0, strerror_r=0x8049e20 2). dlsym version:

  • 0

1). print function address directly:

printf("strerror=%p, strerror_r=%p\n", strerror, strerror_r);
strerror=0x8049ec0, strerror_r=0x8049e20

2). dlsym version:

rtldDefault= dlopen(0, RTLD_NOW | RTLD_GLOBAL);
dlsym(rtldDefault, "strerror_r"); ==> strerror_r=0xb76544e0

but

dlsym(rtldDefault, "strerror"); ==> strerror=0x8049ec0

3). others:

dlsym((void*)0, "strerror_r") ==> strerror_r=0xb76544e0
dlsym((void*)-1, "strerror_r") ==> strerror_r=0xb76544e0

How can I get strerror_r=0x8049e20 using dlsym()?

I have already print the address of strerror_r first, then call dlsym().

strerror_r=0xb76544e0 is wrong address, my call strerror_r with this address just do nothing.

  • 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-09T13:30:05+00:00Added an answer on June 9, 2026 at 1:30 pm

    If you look at the declaration of strerror_r in /usr/include/string.h:

    /* Reentrant version of strerror'.
    There are 2 flavors of
    strerror_r’, GNU which returns the string
    and may or may not use the supplied temporary buffer and POSIX one
    which fills the string into the buffer.
    To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L
    without -D_GNU_SOURCE is needed, otherwise the GNU version is
    preferred. */
    [and then some quite confusing declarations]

    Compiling a sample program with gcc -save-temps and default configuration, I get the following precompiled declaration:

    extern int strerror_r (int __errnum, char *__buf, size_t __buflen) 
        __asm__ ("" "__xpg_strerror_r") __attribute__ ((__nothrow__ , __leaf__))
        __attribute__ ((__nonnull__ (2)));
    

    So it looks like the strerror_r function is linked to the symbol __xpg_strerror_r instead.

    Indeed, a check of the generated binary objdump -t a.out | grep strerror:

    00000000      DF *UND*  00000000  GLIBC_2.3.4 __xpg_strerror_r
    

    So, asking your question, just do dlsym(rtldDefault, "__xpg_strerror_r").

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

Sidebar

Related Questions

At runtime I need to print out an address, and then find which function
I write a test which print the content of argv[0]--the address of main function's
I want to print list of image address in jquery function using php(adodb) and
I want to print the address of an access variable (pointer) for debugging purposes.
I have a geocoding function that is pulling the address values entered into a
Related to my other question How can I get the address (acctual function pointer)
I am trying to have a function return a boolean and an address in
I have a virtual machine, which on VM_Create passes the address of a function
I have a small function that tries to print the fragment offset of an
I have a C-function that allocates memory at the address passed to and is

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.