www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - shared library

reply "Igor Lesik" <curoles yahoo.com> writes:
I was able to build D runtime shared library (.so). The test app dies with 
segmentation fault, I am debugging it; decided to share.

To reproduce my results one can load makefile from here:
http://www.curoles.com/j/dso/so.mak
(drop it into the runtime directory and call make -f so.mak)

The problem happens in main() (defined in src/rt/dmain2.d) when first time a 
library function is called.
The PLT entry look good, but jump to GOT seems to be wrong. I expect to see 
address of got.plt section
(readelf -S ./test), instead the address for indirect jump is taken from 
some stack variable, the address
is invalid and segmentation fault happens.

I have written some notes here (gdb session):
http://www.curoles.com/j/dso/dso.html

Igor
Mar 05 2010
parent reply "Igor Lesik" <curoles yahoo.com> writes:
Walter, Don, and All

Function codgen() in dmd/backend/cgcod.c has lines like:
if (0 && config.flags3 & CFG3pic)
so the PIC flag is ignored (2.040)
Do I understand it right?

I look on this code because value in %ebx (PIC register) does not look right 
when I debug
application that is dynamically linked with runtime shared library.

Also 
Mar 06 2010
parent "Igor Lesik" <curoles yahoo.com> writes:
Walter, Don, and All

Function codgen() in dmd/backend/cgcod.c has lines like:
if (0 && config.flags3 & CFG3pic)
so the PIC flag is ignored (2.040)

Do I understand it right?

I look on this code because value in %ebx (PIC register) does not look
right when I debug application that is dynamically linked with runtime
shared library.

Thanks,
Igor

"Igor Lesik" <curoles yahoo.com> wrote in message 
news:hmujil$ntp$1 digitalmars.com...
 Walter, Don, and All

 Function codgen() in dmd/backend/cgcod.c has lines like:
 if (0 && config.flags3 & CFG3pic)
 so the PIC flag is ignored (2.040)
 Do I understand it right?

 I look on this code because value in %ebx (PIC register) does not look 
 right when I debug
 application that is dynamically linked with runtime shared library.

 Also
 

Mar 06 2010