Getting the address of an assembly veneer
Dave Higton (1515) 3526 posts |
I need to put an assembly veneer round a C function because the function needs the value of R11, and the function prologue overwrites R11. I’ve got an assembly language file that exports the label representing the start of the veneer. I can reference this from the C, but the value I get does not represent the address of the veneer – of course that address is not known until the moment the module is initialised. I see that David Pilling’s PDumperSP simply references his label and presumably gets the right answer. I don’t understand the discrepancy between his code and mine, and how they work. Currently I’m using GCC and asasm (I changed over from the DDE because, IIRC, the C couldn’t reference the veneer’s label despite it being GLOBAL). Any help would be welcome. |
Stuart Swales (8827) 1357 posts |
In ObjAsm you have to explicitly |
Jeffrey Lee (213) 6048 posts |
Norcroft (and I assume GCC, when producing modules) relocates symbols using different methods depending on the type of symbol – i.e. writeable data, read-only data, code, etc. Code is generally referenced directly from the module body, while writeable data will generate references to the module workspace. I’m not sure offhand how read-only data & writeable code are handled (I think Norcroft has a habit of putting Things to check:
|
Dave Higton (1515) 3526 posts |
Thank you, Jeffrey. It was the second point. (The code was already code and readonly, though also rel and with a different name but I don’t think those made a difference.) Declaring it as a function should be obvious, I suppose, and it is now! Still doesn’t work overall, but at least I get the right address now, so that’s one layer of the onion removed. |