LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-30-2010, 05:21 PM   #1
rmknox
Member
 
Registered: May 2010
Posts: 354

Rep: Reputation: 34
how do I control the segment selector assigned to a section


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.
 
Old 05-30-2010, 05:45 PM   #2
fruttenboel
Member
 
Registered: Jul 2008
Location: Tilburg NL
Distribution: Slackware 14.2 ciurrent, kernel 3.18.11
Posts: 270

Rep: Reputation: 48
Quote:
Originally Posted by rmknox View Post
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...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Selector Sluggish daniell Linux - Newbie 2 08-24-2009 12:58 PM
Windows Selector Sluggish daniell Linux - Newbie 2 08-24-2009 07:40 AM
x window manager selector? ninja master Linux From Scratch 2 03-02-2009 08:49 PM
Acronis OS Selector vi0lat0r Linux - General 2 12-20-2004 06:31 PM
Better background selector for Gnome? euth665667 Linux - Software 0 07-01-2004 06:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration