flat assembler
Message board for the users of flat assembler.

Index > Main > namespaces

Author
Thread Post new topic Reply to topic
pepe



Joined: 26 Feb 2015
Posts: 19
pepe 29 Mar 2024, 11:50
Hello, asking again ... Embarassed

is there a way to limit names' scope within a source file? (not talking about local names)

the problem is the following:
i am building a custom binary image from several segments using virtual address spaces containing loaded (file) and compiled data, using load/store.
It happens that i need some functions to be physically present in multiple segments, so i decided to define macros for these to quickly 'instantiate' them in the virtual segments, but the global function names conflict with eachother within the different virtual blocks. I've been scratching my head for some time now about how to avoid these conflicts without having to deal with scrambled function names within the different segments.
Any ideas welcomed,
thank you,
pepe
Post 29 Mar 2024, 11:50
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 29 Mar 2024, 13:58
fasm 2 and its fasmg engine have NAMESPACE / END NAMESPACE directives for this purpose. It is in fact one of the cornerstones of fasmg's design and what pushed me to start developing it.
Post 29 Mar 2024, 13:58
View user's profile Send private message Visit poster's website Reply with quote
pepe



Joined: 26 Feb 2015
Posts: 19
pepe 29 Mar 2024, 14:26
yes, i kind of saw it from the corner of my eyes, but i am using fasmarmw, which is built on v1 afaik... :s
Post 29 Mar 2024, 14:26
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 29 Mar 2024, 20:30
Moving to non-x86 forum. The post doesn't appear to be anything Windows specific
Post 29 Mar 2024, 20:30
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 29 Mar 2024, 20:44
Perhaps an option is to use struc instad of macro and add a leading dot to the label names.
Code:
struc foo_a {
  .function1: 
  ;...
  mov pc,lr
}
struc foo_b {
  .function1: 
  ;...
  mov pc,lr
}

format ...

section ...
bar foo_a
baz foo_b

;...
bl bar.function1
bl baz.function1    
Post 29 Mar 2024, 20:44
View user's profile Send private message Visit poster's website Reply with quote
pepe



Joined: 26 Feb 2015
Posts: 19
pepe 01 Apr 2024, 11:28
well, the problem is not architecture specific, it looks like it is because it can be worked around in fasm2 easily, but this is not what fasmarm is built on. The problem is specific to fasm 1 regardless of the architecture. That's why it was posted in the main thread.
(And FASM is not windows specific, either)

2: i was experimenting with struc as well, but came up with nothing useful (might be my lack of understanding as well). Gonna give your example a try. I dropped the whole idea for now as it seems to be taking more efforts than it deserves in my current project, so just put my functions with different name prefixes in the segments requiring them. Not very nice but that's it.

thank you ,
pepe
Post 01 Apr 2024, 11:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 01 Apr 2024, 11:40
You posted to Windows originally. But no matter it can also live in Main.


Last edited by revolution on 01 Apr 2024, 12:10; edited 1 time in total
Post 01 Apr 2024, 11:40
View user's profile Send private message Visit poster's website Reply with quote
pepe



Joined: 26 Feb 2015
Posts: 19
pepe 01 Apr 2024, 11:49
did i? oops, yeah, that was a mistake then... sorry.
Post 01 Apr 2024, 11:49
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.