Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

stabs common symbols relocation



Hello,

I'm finishing the last loose ends before the first full release of the Free Pascal Compiler for Darwin/Mac OS X, but one of them has me stumped. It's regarding stabs generation for global interface variables in units.

For the non-Pascal people: these are the same as globals in C, except that they are automatically encapsulated in a namespace (so you can have multiple units with a variable with the same name in the interface). The name mangling used is U_UNITNAME_VARIABLENAME. Now, under other OS'es, we generate them like this (for a variable "a" in the interface of unit "unit1"):

# [6] a: longint;
.comm U_UNIT1_A,4
.stabs "A:S1",40,0,6,U_UNIT1_A

This does not work under Darwin however, as this stabs is not relocated. If you try to print "a", you get a "Cannot access memory at address 0x0" error from gdb.

I've then tried to use a workaround someone else already devised for variables in Fortran common blocks:

.comm U_UNIT1_A,4
.stabs "U_UNIT1_A",226,0,6,0
.stabs "A:V1",40,0,6,0
.stabs "U_UNIT1_A",228,0,6,0
.stabs "U_UNIT1_A:G1",32,0,6,0

What this does, is define a common section in the stabs, define A as member of it, and at the end say that the address of this common block is the address of the global symbol U_UNIT1_A.

Although this produces the correct results, this way the symbol A is only accessible from within functions residing in the same compilation unit (object file) as this common block. This is not the desired behaviour, as it's a global symbol that should be visible everywhere.

I've also tried

.comm U_UNIT1_A,4
.stabs "A:G1",32,0,6,U_UNIT1_A

but that doesn't work either as gdb discards the address you specify for global symbols using the last parameter.

So is there any way to achieve this? (a globally visible debugging symbol with a different name than the common section it refers to)

Thanks,


Jonas
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.