flat assembler
Message board for the users of flat assembler.
Index
> Linux > write zero term. string located in stack space |
Author |
|
revolution 27 Apr 2005, 09:45
I am not familiar with Linux but I will try to help if I can.
try this: Code: enter 8,0 instead of: Code: enter 2,0 |
|||
27 Apr 2005, 09:45 |
|
fly 27 Apr 2005, 10:12
thx! unfortunately this doesn't affect the output of the prog. i've tried different values for this parameter. also i have verified the memory location at [rbp]-[rbp-7], the bytes are written correctly into it.
|
|||
27 Apr 2005, 10:12 |
|
revolution 28 Apr 2005, 01:51
The only other thing I can think of is if SS:base <> DS:base. Does Linux use the same base address for both segment selectors?
|
|||
28 Apr 2005, 01:51 |
|
Tomasz Grysztar 28 Apr 2005, 06:50
In long mode it's impossible for them to have different bases.
|
|||
28 Apr 2005, 06:50 |
|
vid 28 Apr 2005, 11:38
if it wouldn't, you would have to use FAR pointers for stack variables, and thus all external pointers (about which you don't know if they point to stack or to data) would have to be FAR, so this way you could forget about coding in C-likes
|
|||
28 Apr 2005, 11:38 |
|
Endre 28 Apr 2005, 11:44
by using Write you destroy (with push's) data on the stack you've just put on it with those mov [ebp+xxx] statements. After mov's you have to update esp
Code: sub esp, length_of_my_data_on_the_stack Code: add esp, length_of_my_data_on_the_stack |
|||
28 Apr 2005, 11:44 |
|
fly 28 Apr 2005, 12:19
i use the "enter 8, 0" instruction, therefore the stack pointer should be set rigth (is that correct?)
as privalov mentioned it, the 64bit mode uses flat memory model (non-segmented), and all segment-base adresses have a value of 0 (->amd64 prog manual pg32). so that also cannot be the reason. now i'm try to follow vid's proposal and write a mallac/dealloc routine and store only pointers to my local variables on the stack |
|||
28 Apr 2005, 12:19 |
|
Endre 28 Apr 2005, 18:07
fly wrote: i use the "enter 8, 0" instruction, therefore the stack pointer should be set rigth (is that correct?) A A Even it didn't count either that your 'leave' will never be executed. What if you write merely ELF instead of ELF64 after the format directive? It might be that you need a 64 bit kernel for running ELF64 but you just have a 32 bit one. |
|||
28 Apr 2005, 18:07 |
|
fly 28 Apr 2005, 20:35
thanks for the hint with the leave instruction!
i hadn't minded the possibility to try the code in 32bit mode, and i'm wonder about - it works fine. i had changed the code as you described it (find/replace r**->e** and use ELF instead of ELF64). the 32bit executable emit: A A but the 64bit executable emit: A now i'm completely perplexed running elf64 executables should be no problem (amd64 athlon with mandrake 10.1 64bit distro) i attached the two files, perhaps anyone with a 64bit system want to try it...
|
|||||||||||
28 Apr 2005, 20:35 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.