Problem with Virtual Memory Subcontexts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear all,

I'm having a rather odd problem, and I think it all boils down to what
compiler/linker
flags I am using. As an overview, I am trying to implement subcontexts in
virtual
memory. Basically, I am writing two programs: a server program and a client
program.
The server program creates a file, foo, and dumps all of its memory into
this file
(by parsing /proc/self/maps) including, hopefully, any functions that
happen to be
implemented within it. The client program processes foo and maps all of the
memory within it into its own virtual memory. Ideally, once this happens,
the client program can make function calls into the server programs memory,
even
through the server program has already terminated.

Here's where things get sticky. Say that I have functions "bar" and "baz"
in the server
program that contains a very simple print statement within it. The problem
presents
itself when a client program tries to call this function. If "bar" has been
called
directly in the execution of the server program (i.e., when it is dumping
its memory
to the file), everything works just fine. If instead bar is NOT called in
the server
program in this manner, a segmentation fault occurs. What's even weirder is
that
if "bar" is called but "baz" isn't, a call to "baz" does NOT cause a
segmentation
fault.

When I analyze the segmentation fault in gdb, it seems like the stack has
been corrupted
somewhere. A "where" command eventually elicits an address of 0x0.

I've been compiling using -fPIE for the compiler and -pie for the linker,
as the
code needs to be position independent so that the memory locations that the
client
server is trying to map don't overlap with its own maps. Other than that,
I've
tried every combination of flags known to man. I've tried various
combinations of:

-fno-plt
-Wl,-z,now
-Wl,-z,relro

I tried these because I thought the issue might be the difference between
the
PLT/GOT in the server program vs. in the client program. I also thought
that the
problem might lay in the generation of the PLT/GOT in the server program.
Both of
these debugging paths seem to have been misguided, as neither of them were
fruitful.

-static-pie
-fPIC
-pic

My understanding of these is that under my circumstances, -fPIE and -pie do
the same thing as -fPIC and -pic.

Any and all help, feedback, or guidance would be greatly appreciated.

Many thanks,
Fay




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux