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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:16:41+00:00 2026-05-24T13:16:41+00:00

I have a Solaris process, which is a C++ application that is loaded by

  • 0

I have a Solaris process, which is a C++ application that is loaded by ld with a few .so libraries. This application has a function that gets a return address in the calling function and then tries to determine the name of the said calling function.

If I use dladdr(3) for that, it does not always put what I expect to see in Dl_info::dli_sname. It looks like it returns a name of a function that is not nearest below or at the pointer value. If I take the pointer value and look at the output of nm, I can match the value to the exact function I expect it to be.

I am wondering if there is a way to retrieve a symbol map for a process and let it search for the function name without using dladdr(3). I am especially interested to get a symbol map not just for the executable itself but also for all .so libraries that it has loaded.

I’m running on Solaris10/SPARC and I’m using gcc 4.2.x.

Thank you!

  • 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-24T13:16:43+00:00Added an answer on May 24, 2026 at 1:16 pm

    I have tried a simple test using dladdr() on Solaris 10/SPARC (but caveats: GCC 3.4, straight C), and this works fine for me:

    #include <dlfcn.h>
    #include <stdio.h>
    
    void print_name(char *name, void *addr);
    void print_name_by_dladdr(void *addr);
    
    int main(int argc, const char *argv[])
    {
        print_name("main", (void *)&main);
        print_name("print_name", (void *)&print_name);
        print_name("printf", (void *)&printf);
        return 0;
    }
    
    void print_name(char *name, void *addr)
    {
        (void)printf("Getting name of function %s() at 0x%x\n", name, addr);
        print_name_by_dladdr(addr);
    }
    
    void print_name_by_dladdr(void *addr)
    {
        Dl_info dli;
        if(!dladdr(addr, &dli)) {
            perror("dladdr()");
            exit(1);
        }
        (void)printf("  %s\n", dli.dli_sname);
    }
    

    Output:

    Getting name of function main() at 0x10714
      main
    Getting name of function print_name() at 0x10778
      print_name
    Getting name of function printf() at 0x209b8
      _PROCEDURE_LINKAGE_TABLE_
    

    This also works correctly if I write (for example)

        print_name("main", (void *)&main + 4);
    

    You say you can resolve correctly against the output of nm so possibilities seem limited… are you certain that the return address is being derived or passed correctly to your resolver function? I guess you are using the GCC builtins for this? I have tested __builtin_return_address(0) and this also works fine for me. If you are using the GCC builtins, did you call __builtin_extract_return_address() (see above page for details, mentions SPARC explicitly)? Can you post your code?

    Can you stretch slightly to “process re-reading it’s own binary/shared object files”? If so then libelf may be a way forwards. This is exactly what some of those utilities you mention are using, eg nm: http://cr.opensolaris.org/~devnull/6515400/usr/src/cmd/sgs/nm/common/nm.c.html

    This introductory article from sun.com might be of use (warning: article is 10 years old).

    This isn’t as nice as doing native introspection and it’s odd that dladdr(3C) doesn’t work 🙁

    Alternative intermediate: have you tried the RTLD_DL_SYMENT flag to dladdr1(3C) (and then perhaps borrow from nm.c as above on the returned ELF sym)?

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

Sidebar

Related Questions

I have an application that runs on a server under Solaris. This application exports
On Solaris 9 and 10, both x86 and Sparc, we have a process that
I have an application that's a mix of Java and C++ on Solaris. The
I have a Java process which is dying after running for a few days
I have a Solaris sparc (64-bit) server, which has 16 GB of memory. There
I have a server application that forks several child processes. When showing the processes
I have a process which suddenly hanged and is not giving any core dump
I have been tasked with improving the performance of a slow running process which
At work we have several Solaris servers. Each server runs apache which we compiled
Problem: I have a project which I'm porting from Solaris/Lex/Yacc to Linux/Flex/Bison + Autotools.

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.