Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

dlsym(RTLD_NEXT,...) is broken

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
14 posts • Page 1 of 1
Author
Message
linux_girl
Apprentice
Apprentice
Posts: 287
Joined: Fri Sep 12, 2003 12:10 am
Contact:
Contact linux_girl
Website

dlsym(RTLD_NEXT,...) is broken

  • Quote

Post by linux_girl » Thu Dec 30, 2004 4:10 am

Code: Select all

gcc -o libsab.so -shared -ldl -D_USE_GNU test.c
test.c: Dans la fonction « malloc »:
test.c:12: error: `RTLD_NEXT' undeclared (first use in this function)
test.c:12: error: (Each undeclared identifier is reported only once
test.c:12: error: for each function it appears in.)
test.c: Dans la fonction « free »:
test.c:25: error: `RTLD_NEXT' undeclared (first use in this function)
test.c: Dans la fonction « glBegin »:
test.c:37: error: `RTLD_NEXT' undeclared (first use in this function)
the test.c

Code: Select all

#include <stdio.h>
#include <GL/gl.h>
#include <dlfcn.h>

//#define RTLD_NEXT      ((void *) -1)


void * malloc(size_t size) {
  static void *(*sys_malloc)(size_t) = NULL;
  if (!sys_malloc) {
    if (!(sys_malloc = (void *(*)(size_t)) dlsym(RTLD_NEXT, "malloc"))) {
      perror("cannot fetch system malloc\n");
      exit(1);
    }
  }
  fprintf(fopen("/dev/pts/6","a"),"%s%d%s" ,"malloc(",size,")\n");
  return sys_malloc(size);
}

void free(void *p) {
  static void (*sys_free)(void *) = NULL;
  if (!sys_free) {
    if (!(sys_free = (void (*)(void *)) dlsym(RTLD_NEXT, "free"))) {
      perror("cannot fetch system free\n");
      exit(2);
    }
  }
  fprintf(fopen("/dev/pts/6","a"),"%s%x%s","free(", p,")\n" ); 
  sys_free(p);
}

void glBegin( GLenum mode ){
  static void (*m_glBegine)(GLenum) =NULL;
  if(!m_glBegine){
    m_glBegine=  (void (*)(GLenum)) dlsym(RTLD_NEXT,"glBegin");
  }
  printf ("glBegin(%d)\n",mode);
  m_glBegine(mode);
}
and yes i am trying to hook a pUnk not busting GameS

any idea why on how to #define RTLD_NEXT ......... ??????????????????? :evil: :evil:

Code: Select all

grep -n RTLD_NEXT /usr/include/dlfcn.h 
32:/* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT
36:# define RTLD_NEXT   ((void *) -1l)
even adding # define RTLD_NEXT ((void *) -1l) didnt help !!! :?: :?: :?:

Edit: removed annoying 'why GENTOO SUCKS ASS' from subject line --ian!
:D :D
Top
linux_girl
Apprentice
Apprentice
Posts: 287
Joined: Fri Sep 12, 2003 12:10 am
Contact:
Contact linux_girl
Website

Crassy SHIT AGAIN

  • Quote

Post by linux_girl » Thu Dec 30, 2004 4:33 am

Code: Select all



#define _GNU_SOURCE
#include <stdio.h>
#include <GL/gl.h>
#include <dlfcn.h>

//#define RTLD_NEXT      ((void *) -1)


void * malloc(size_t size) {
  static void *(*sys_malloc)(size_t) = NULL;
  if (!sys_malloc) {
    if (!(sys_malloc = (void *(*)(size_t)) dlsym(RTLD_NEXT, "malloc"))) {
      perror("cannot fetch system malloc\n");
      exit(1);
    }
  }
  fprintf(fopen("/dev/pts/6","a"),"%s%d%s" ,"malloc(",size,")\n");
  return sys_malloc(size);
}


void free(void *p) {
  static void (*sys_free)(void *) = NULL;
  if (!sys_free) {
    if (!(sys_free = (void (*)(void *)) dlsym(RTLD_NEXT, "free"))) {
      perror("cannot fetch system free\n");
      exit(2);
    }
  }
  fprintf(fopen("/dev/pts/6","a"),"%s%x%s","free(", p,")\n" ); 
  sys_free(p);
}

void glBegin( GLenum mode ){
  static void (*m_glBegine)(GLenum) =NULL;
  if(!m_glBegine){
    m_glBegine=  (void (*)(GLenum)) dlsym(RTLD_NEXT,"glBegin");
  }
  printf ("glBegin(%d)\n",mode);
  m_glBegine(mode);
}



Code: Select all

$gcc -o libsab.so -shared -ldl -D_USE_GNU test.c
export LD_PRELOAD=`pwd`/libsab.so && ls 
Seg Fault ...
any help befor yje holyday ends will be nice .
:D :D
Top
rhill
Retired Dev
Retired Dev
User avatar
Posts: 1629
Joined: Fri Oct 22, 2004 9:58 am
Location: sk.ca

  • Quote

Post by rhill » Thu Dec 30, 2004 4:37 am

No.
Top
linux_girl
Apprentice
Apprentice
Posts: 287
Joined: Fri Sep 12, 2003 12:10 am
Contact:
Contact linux_girl
Website

  • Quote

Post by linux_girl » Thu Dec 30, 2004 4:46 am

dirtyepic wrote:No.
wtf ?
:D :D
Top
Dizzutch
Guru
Guru
User avatar
Posts: 463
Joined: Tue Nov 09, 2004 8:29 pm
Location: Worcester, MA
Contact:
Contact Dizzutch
Website

  • Quote

Post by Dizzutch » Thu Dec 30, 2004 4:47 am

the code you posted shows your #define commented out, i hope you're not stupid.
for the rest, compile it on a different machine, if it doesn't compile their either it's not gentoo that sucks. Until then, don't come to conclusions
Top
Godsmacker777
Apprentice
Apprentice
Posts: 205
Joined: Tue May 04, 2004 8:47 pm
Location: Fenway area, Boston Massachusetts :O)

  • Quote

Post by Godsmacker777 » Thu Dec 30, 2004 4:56 am

what a harsh assumption, haven't you the humility to first assume you may have made a mistake? You have to then assume that if we're talking about linux (which we are), then there must be a way. I am just learning c, so I have no idea what the issue is, though you posted a rather annoying statement in your subject, one that is tough to pass by without wondering what is wrong (with you that is).


~Goodluck~
Why must we hear what system you're running gentoo on, especially if all you've got is a measly gig of ram or 3gHz processor?

I want to see signatures boasting 25 cpu clusters and blade severs, or a big 'ole onyx..anyone running gentoo on an onxy??
Top
linux_girl
Apprentice
Apprentice
Posts: 287
Joined: Fri Sep 12, 2003 12:10 am
Contact:
Contact linux_girl
Website

  • Quote

Post by linux_girl » Thu Dec 30, 2004 5:10 am

i ve been playing with dlopen/sym a lot while on REDHAT . now that i ve lost 2days of Hollydays to replacer my REDHAT with a GENTOO.

i thx that my redhat release have made things ok! never got any problemes.

i had to say gentoo ebuild maker sucks especialy @glibc ass becaus they have messed a suche shit!

since i am on GENTOO i got major headache from fseek()/ftell (i had to replace them with fseeko/ftello )

GOD dam it! My GENTOO expericen was Totaly like a pain in my ass.
:D :D
Top
Arker
Apprentice
Apprentice
Posts: 205
Joined: Tue Sep 10, 2002 12:01 pm
Contact:
Contact Arker
Website

  • Quote

Post by Arker » Thu Dec 30, 2004 6:06 am

If only Gentoo and Redhat used the same compiler...

I'll not even bother looking at the posted code.

~djc
*LIK*

My other computer is your Windows box.
Top
Godsmacker777
Apprentice
Apprentice
Posts: 205
Joined: Tue May 04, 2004 8:47 pm
Location: Fenway area, Boston Massachusetts :O)

  • Quote

Post by Godsmacker777 » Thu Dec 30, 2004 6:12 am

I am sorry to hear you have had such a terrible experience. It is too bad no one warned you how the gentoo experience tends to be a long and arduous (for some). Some people just aren't cut out for gentoo (or linux for that matter). It's too bad, and it's too bad you are so upset.

Learn to speak and you should be on a good start.

Struggling and learning how to do something can be the most rewarding, sounds like this is a really a case of the American "I want it, I want it now, and I'll be pissed if I don't get it the way I want it..." That's really too bad.
Why must we hear what system you're running gentoo on, especially if all you've got is a measly gig of ram or 3gHz processor?

I want to see signatures boasting 25 cpu clusters and blade severs, or a big 'ole onyx..anyone running gentoo on an onxy??
Top
moocha
Watchman
Watchman
Posts: 5722
Joined: Tue Oct 21, 2003 6:45 pm

  • Quote

Post by moocha » Thu Dec 30, 2004 6:30 am

linux_girl:
(a) Use libtool. That's what it's for. You roll your own at your own risk. Your code is failing because you're making assumptions that dynamically loading symbols is working uniformly across all distributions. Dream on...
(b) Learn to be polite if you seek help. Insulting people will only get you being shown the finger. And rightly so.
Military Commissions Act of 2006: http://tinyurl.com/jrcto

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety."
-- attributed to Benjamin Franklin
Top
Genone
Retired Dev
Retired Dev
User avatar
Posts: 9656
Joined: Fri Mar 14, 2003 6:02 pm
Location: beyond the rim

  • Quote

Post by Genone » Thu Dec 30, 2004 6:53 am

btw, our libc comes mostly from redhat ...
Top
behd
Apprentice
Apprentice
User avatar
Posts: 155
Joined: Tue Feb 11, 2003 2:05 pm

  • Quote

Post by behd » Thu Dec 30, 2004 8:48 am

rofl... criticizing gentoo but regged on the forum since one year :lol:

didn't you get proper support from redhat ?
Top
Pink
Veteran
Veteran
User avatar
Posts: 1062
Joined: Thu Jul 24, 2003 11:52 am

  • Quote

Post by Pink » Thu Dec 30, 2004 9:39 am

linux_girl wrote:GOD dam it! My GENTOO expericen was Totaly like a pain in my ass.
Then use something else. Unless I am mistaken, no one is forcing you to use Gentoo, Linux or any other operating system.

If you want Linux then use one of the other few dozen distros out there. Gentoo is not for everyone.

If you have a problem with Linux then use windows.

Believe me, no body here will lose a seconds thought or sleep over what you think about Gentoo.

Good luck in your new distro of choice (the keyword there is choice!).

Bye bye.
Top
linux_girl
Apprentice
Apprentice
Posts: 287
Joined: Fri Sep 12, 2003 12:10 am
Contact:
Contact linux_girl
Website

  • Quote

Post by linux_girl » Thu Dec 30, 2004 4:53 pm

behd wrote:rofl... criticizing gentoo but regged on the forum since one year :lol:

didn't you get proper support from redhat ?
using REDHAT AT work
reinstalling gentoo@home every time portage blow/brok
:D :D
Top
Post Reply

14 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic