Re: problem on /proc/self/exe and /proc/num/exe



"William" <snowingbear@xxxxxxxxx> writes:

But if I run test as a ld, compiled with
"gcc -Wl,--dynamic-linker test hello.c -o hello". It will fail on i386
and x86_64, but OK on ia64.

The problem is that your "test" ld is linked to load at the same
address as hello:

$ objdump -p ./hello | grep LOAD | head -1
LOAD off 0x00000000 vaddr 0x08048000 paddr 0x08048000 align 2**12
$ objdump -p ./test | grep LOAD | head -1
LOAD off 0x00000000 vaddr 0x08048000 paddr 0x08048000 align 2**12

You have to get your "test ld" out of the way by linking it at a
different address (using a linker script), or get your "hello"
executable out of the way by building it as a position-independent:

$ gcc -g junk.c -o test -static &&
gcc junk.c -Wl,--dynamic-linker=./test &&
./a.out
pid is 16060
string is /proc/16060/exe
readlink: No such file or directory

$ gcc -fPIC -pie junk.c -Wl,--dynamic-linker=./test &&
./a.out
pid is 16066
string is /proc/16066/exe
real file is /home/paul/a.out

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
.



Relevant Pages

  • Re: Article on Herbert Schildt, author of C Unleashed, repaired on wikipedia
    ... that deliberately went one beyond the end of the string, ... Within its framework, which sucks, it is a correct program. ... To do this you changed a value parameter to a reference parameter and ... this makes the recursion go wrong. ...
    (comp.programming)
  • Re: Recursive functions
    ... recursion is certainly a natural way of defining the ... it IS totally inappropriate to compute ... not mean "inefficient in a typical C implementation". ... If I had an actual requirement to print the string ...
    (comp.lang.c)
  • Re: Three Kinds of Logical Trees
    ... > I think this is just a representation issue. ... > I do have a number, but I am only ttreating as a string. ... I was attempting to isolate the question of tree structure; ... it's not much of an issue; no one uses recursion much. ...
    (comp.databases.theory)
  • Is this recursion?
    ... This is the ole reverse a string classroom assignment. ... Recursion is soemthing I never quite understood till now but as I ... public static void reversal{ ...
    (comp.lang.java.help)
  • Re: Recursive functions
    ... function to compute the length of a string. ... to define the length of a finite sequence in terms of recursion ... :) I've never taught any programming courses, ...
    (comp.lang.c)