flat assembler
Message board for the users of flat assembler.

Index > Heap > Flat C compiler

Author
Thread Post new topic Reply to topic
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Anybody know of a compiler that can do raw compilations. The ones I have map strings somewhere else. It's stupid. Evil or Very Mad

Or are there some switches I have to toggle on the same compilers?


Last edited by typedef on 11 May 2012, 15:33; edited 2 times in total
Post 11 May 2012, 09:49
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1412
Location: Toronto, Canada
AsmGuru62
"map the string somewhere else"??... I do not follow.
Which string?
Post 11 May 2012, 15:04
View user's profile Send private message Send e-mail Reply with quote
Stephen



Joined: 13 Aug 2011
Posts: 30
Stephen
If you look in the macro section you'll find a bunch of print macros for C & Basic like print functions. They could probably be translated to C macros....
Post 11 May 2012, 15:14
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Stephen wrote:
If you look in the macro section you'll find a bunch of print macros for C & Basic like print functions. They could probably be translated to C macros....


Well, I'm not talking about print functions in particular. I have a local string buffer and I always find it at some random address in OllyDbg.

I wish there was such a compiler.
Post 11 May 2012, 15:37
View user's profile Send private message Reply with quote
bubach



Joined: 17 Sep 2004
Posts: 341
Location: Trollhättan, Sweden
bubach
Do you mean that it's put into the .data section somewhere and you want it in the middle of your code? Most compilers use sections stricly, but you could use the #pragma thing to override and start a new section that perhaps will be left untouched. I have no experience in this, but i'd have to guess something along those lines would work if all optimizations are off.
Post 11 May 2012, 16:27
View user's profile Send private message Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 140
SFeLi
typedef, you will need a linker which is able to write binary files in order to do that. Use ld for example or write your own.
Post 11 May 2012, 18:11
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1412
Location: Toronto, Canada
AsmGuru62
Oh, I see now.
I am writing a FASM code generator (for the IDE), which will do same thing, but
all string constants will be put together, of course.
Even then the exact location of a text will not be certain if the
code changes: some other text becomes larger, smaller and the whole
layout will change.
Post 11 May 2012, 20:48
View user's profile Send private message Send e-mail Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
@bubach Yeah. I explained it like a noob there, forgive me. I meant the .data section of course.

@SFeLi
I just resorted to passing the arguments on stack (by using inline assembly). Like so:

Code:
push  0x00612E62       ;file name 'b.a'
push  esp                   ;pointer to filename
push  ...
call  [CreateFileA]
add esp , 4
    


I have bad experiences with compiler settings.

@AsmGuru62
Which IDE, Pelles C or Visual Studio ?
Post 11 May 2012, 21:04
View user's profile Send private message Reply with quote
bubach



Joined: 17 Sep 2004
Posts: 341
Location: Trollhättan, Sweden
bubach
This stackoverflow post describes that creating a char array (instead of string) will put it on the stack, and also shows how to pass it to functions:
http://stackoverflow.com/questions/308279/c-strings-vs/308724#308724

I'm not sure if this setting to stack is going to be in the correct location for you, but at least it won't be saved in the .data section

i'm a C noob, but i would think that almost anything is possible - the problem comes down to how the stdlib wants you to pass stuff... for internal functions it might work.
Post 11 May 2012, 22:13
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
bubach These conclusions are made after debugging. They are passed as pointers of course not the whole string itself.
Post 11 May 2012, 22:28
View user's profile Send private message Reply with quote
malpolud



Joined: 18 Jul 2011
Posts: 344
Location: Broken hippocampus
malpolud
I'm not sure if that works in C (it should), but in CPP you just want to create a constant pointer and set it. Like this:
Code:
int * const pointer = &something;    
Post 11 May 2012, 23:20
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
malpolud wrote:
I'm not sure if that works in C (it should), but in CPP you just want to create a constant pointer and set it. Like this:
Code:
int * const pointer = &something;    


Compiler will still put it in the .data section. It's a design issue I think and not part of the ISO C rules/guidelines.
Post 11 May 2012, 23:40
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1412
Location: Toronto, Canada
AsmGuru62
@typedef: the FASM code gen. is in my IDE for OO Assembler.
Post 11 May 2012, 23:50
View user's profile Send private message Send e-mail Reply with quote
dancho



Joined: 06 Mar 2011
Posts: 74
dancho
Code:
#pragma const_seg("STR")
       
char* str = "hello world\n";

#pragma const_seg()

#pragma comment(linker,"/SECTION:STR,R")
    


this is tested and it is working in the VS 2008 ,
new section is created with IMAGE_SCN_CNT_INITIALIZED_DATA and IMAGE_SCN_MEM_READ characteristics but
it is not working in the latest Pelles C
Post 12 May 2012, 11:57
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
@dancho Yeah. I know about that. I ran away from Visual Studio because it's doing some weird shit to my code which comes out totally different to the same code compiled with Pelles C.

Well,...
I'm stressing now... I wish I smoked...
Post 12 May 2012, 19:30
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 can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.