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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:15:00+00:00 2026-06-01T15:15:00+00:00

I’m trying to compile Ruby 1.9.3-p125 on AIX 5.3 using xlc_r. I want to

  • 0

I’m trying to compile Ruby 1.9.3-p125 on AIX 5.3 using xlc_r. I want to use the –enable-load-relative but that’s dependent on the dladdr() function to get the pathname of the Ruby shared library and dladdr() isn’t available on AIX. I found an implementation of dladdr() here on root.cern.ch for AIX based on a call to loadquery(L_GETINFO).

The loadquery(L_GETINFO) call gets a list of the binary files that make up a program. So to implement dladdr(), I’m doing a check to see if the address of the function passed to dladdr is between ldinfo_textorg and ldinfo_textorg+ldinfo_textsize. But the address of the function isn’t within this address range for any of the structures returned. Maybe I’m not correctly interpreting the ld_info structure.

I’ve attached the code I’m testing. Any help that can be rendered to these questions will be much appreciated.

#include <sys/types.h>
#include <sys/ldr.h>
#include <stdlib.h>
#include <stdio.h>

typedef struct {
  char* dli_fname;
} Dl_info;

int
dladdr(void* s, Dl_info* i) {
   size_t bufSize = 40960;
   struct ld_info* ldi;
   void *buf;
   int r;

   printf("sym at %lu\n", (ulong)s);
   buf = (void *)malloc(bufSize);
   if (!buf) {
     i->dli_fname = 0;
     return 0;
   }
   r = loadquery((int)L_GETINFO,  buf,  (int)bufSize);
   if (r == -1) {
     i->dli_fname = 0;
     return 0;
   }
   do {
     ldi = (struct ld_info*)buf;
     printf("checking %s, text %lu - %lu\n", ldi->ldinfo_filename, (ulong)ldi->ldinfo_textorg, (ulong)(ldi->ldinfo_textorg + ldi->ldinfo_textsize));
     if ((ldi->ldinfo_textorg <= s)
     &&  (s < (ldi->ldinfo_textorg + ldi->ldinfo_textsize))) {
       i->dli_fname = ldi->ldinfo_filename;
       return 1;
     }
     buf += ldi->ldinfo_next;
   } while (ldi->ldinfo_next);
   i->dli_fname = 0;
   return 0;
}

int
test_func() { 1; }

int
main() {
  Dl_info dli;
  int rc = dladdr((void *)test_func, &dli);
  printf("rc = %d\n", rc);
  if (rc) {
    printf("dli.dli_fname = %s\n", dli.dli_fname);
  }
}

Update 30-Apr-2012:
When I originally posted this question, I was also seeing loadquery(L_GETINFO) cause a segmentation violation when called from a 64-bit program. I can’t live without 64-bit so this was a showstopper for me. This now looks like it’s a problem with the installation of the compiler; other AIX machines can compile and run the code in 64-bit mode.

The stack back-trace looked like this:

.() at 0xf458
usl_getinfo_user(??, ??, ??, ??) at 0x9fffffff00096b8
uloadquery(??, ??, ??, ??, ??, ??, ??) at 0x9fffffff0009b40
loadquery(0x200000002, 0x1000b3f0, 0xa0000000a000, 0x0, 0x0, 0x0, 0x0, 0x0) at 0x900000000043874
dladdr(s = 0x0000000110000900, i = 0x0ffffffffffffa00), line 18 in "dladdr.c"
main(), line 11 in "test_dladdr.c"
  • 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-01T15:15:01+00:00Added an answer on June 1, 2026 at 3:15 pm

    Looks like you need to read more about Pointer Glue on AIX and PowerPC, https://stackoverflow.com/a/1343437/89101 . If you change to:

    int rc = dladdr((void*)*((ulong*)&test_func), &dli);
    

    that will get the actual address of test_func and you’ll get the expected output of finding it in the main program.

    I’m not sure why you get a crash with loadquery for 64-bit. It works on my machine. One thing that looks fishy is

    loadquery(0x200000002, 0x1000b3f0, 0xa0000000a000, 0x0, 0x0, 0x0, 0x0, 0x0) at 0x900000000043874
    

    the 0xa0000000a000 looks to be too large, 40960 in hex should just be 0x00000000a000.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I am trying to understand how to use SyndicationItem to display feed which is
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I want to construct a data frame in an Rcpp function, but when I
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

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.