Originally Posted by rmknox
I see from dumping executables that seg selector 0x10 is assigned to my stack segment and to my data segments (.bss .data COMMON). The code is using 0x08. My question - how can I control this? I've looked at all the command line options and don't see it.
I have a different program that uses 0x10 for code and 0x18 for data.
I note that the second program has i386 in the architecture field in the linker script, whereas the first one referenced has i686.
Is this what causes the difference?
I understand that this architecture field triggers something regarding a library named BFD - is this where I should look? If so, where do I find it? I am runnig fedora.
Is there a way to control the association of sections in the linker script with segment registers? I can set up segments in the gdt and can asign them to segment registers. I can - when writing in assembler - assign code to a section. I can relate a segment in the gdt with a register.But I dont see how to tell the section which segment register it is associated with
Finally I see that the gcc compiler decides - based on how I initialize a variable - whether to put it into bss or data or COMMON. Do I have any control over this?
Thanks for any help you give. At this moment I seem close to a dead end.
Respect the compiler. Even if it is a C compiler.. :0)
The essence of using a compiler (instead of assembly language) is that you don't want to bother with where in memory your executable runs, how it stores variables and fixed data and such things. Let go of it. Or switch back to asm.
Of course Linux will not let you control where in RAM to put your program. It would be a serious security risk if the user would be allowed to run a program at one specific address. Especially if some system task is already occupying that space...