flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
jimjam 29 Jul 2004, 08:21
I figured out my way through the fasm source and implemented my own request.
![]() in masm you go: Code: alias <fakeSymbol>=<realTargetSymbol> I added a keyword or two to fasm: Code: alias 'fakeSymbol' to realTargetSymbol I didn't have alot of time so I just sort of copy&pasted all the stuff relating to extrn and modified it slightly. That's why the syntax looks like it does - that way i didnt have to write much new parsing. So I'm not sure what to do next... What's the procedure for contributing a patch? Is there a preferred format? Any code conventions?[/code] |
|||
![]() |
|
Joshua 29 Jul 2004, 18:02
Would this do?
Code: macro alias var1,var2 { var1 = var2 } to fix , extrn realTargetSymbol alias fakeSymbol to realTargetSymbol |
|||
![]() |
|
Tomasz Grysztar 29 Jul 2004, 18:34
Joshua: no, it won't work when you want to make your alias public.
jimjam: wouldn't it be better if weak external entry was automatically generated when you made some external-based label public? I will try to work on it as soon as I read more about weak externals in MS docs. |
|||
![]() |
|
jimjam 29 Jul 2004, 21:20
Privalov, do you mean it would be better the way I tried originally?
Code: format MS COFF extrn realTargetSymbol label fakeSymbol dword at realTargetSymbol public fakeSymbol Like that? One reason I didn't do it that way is that it is alot of typing for something that could be expressed more clearly with the 'alias' syntax. The real reason I didn't do it that way is because it was easier to fit in with the existing codebase. If you automatically generate the WeakExternal when you get to the 'public fakeSymbol', at "add_public_symbol" in FORMATS.INC, you won't know what that label was referring to. Maybe there's a way to look it up, but I didn't see it right away. Also, the WeakExternal record doesn't stand by itself - it refers to another extrn symbol record by index. Even if you can calculate what symbol the label is pointing to at the point of "add_public_symbol", you don't know at which index the pointed-to extern was outputted. It's not kept track of as far as I could see. The alias syntax I proposed made it easy to implement, that's all. When fasm goes to output an alias record, it outputs an extern right there, so it knows which index to point the WeakExternal at: the one it just outputted. That seems to be the way masm does it as well. You can see that by slightly modifying the original masm example I gave: Code: ; extern realTargetSymbol:DWORD ;;; not actually needed realTargetSymbol EQU 12345 ; symbol just has to be mentioned alias <fakeSymbol>=<realTargetSymbol> END Masm outputs an extern symbol record silently at the point of the alias, then the WeakExternal immediately follows it. It's just easier that way because you don't have to keep track of which extern symbol was output at which symbol table index, just in case someone comes along and tries to publicize an external label, at which point you would have to look it up. I also chose the 'alias' syntax because anyone who is using this feature is probably coming from masm, I thought it would make sense to approximate their syntax. Perhaps 'weakextrn' or 'weakexternal' would be a better keyword, since 'alias' might cause other people's existing code to not compile anymore? Also just to note - I decided to do this because masm dies with internal errors if you play around in any serious way with these WeakExternals. I didn't bother trying to figure out what caused it to crash - maybe the relative order of the different symbols. I dunno. Who cares now? ! ![]() |
|||
![]() |
|
Tomasz Grysztar 30 Jul 2004, 00:50
Quote: If you automatically generate the WeakExternal when you get to the 'public fakeSymbol', at "add_public_symbol" in FORMATS.INC, you won't know what that label was referring to. Maybe there's a way to look it up, but I didn't see it right away. It's very easy to look it up, because this information is anyway needed to make a correct fixups when you refer to such symbol, so it's already kept by all fasm's internal routines. So implementation of this could be much simpler. And I prefer to avoid adding new directives when something can be achieved using the existing ones. |
|||
![]() |
|
Tomasz Grysztar 30 Jul 2004, 11:36
OK, done it, now it needs testing - the attachment contains the pre-release of fasm 1.54 with this feature implemented. It should work just the way you tried it for the first time:
Code: format MS COFF extrn someFunction label someOtherFunction dword at someFunction public someOtherFunction but it should be OK also with other, simpler variants: Code: extrn 'someFunction' as someOtherFunction
public someOtherFunction or Code: extrn someFunction
public someFunction as 'someOtherFunction' Of course you can make the "alias" macro for this purpose. Attachment removed - not it's official release. Last edited by Tomasz Grysztar on 30 Jul 2004, 16:02; edited 1 time in total |
|||
![]() |
|
jimjam 30 Jul 2004, 15:27
Oh wow - awesome! Thanks, Privalov. It works perfectly and you're absolutely right not to add a new keyword.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.