OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 12:20 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Libraries, important.
PostPosted: Mon Apr 16, 2001 11:00 pm 
Hi,

Ive got a question about libraries. How calling them should looks like? call address?It's not the best idea, because I want to have a kind of protection, something that would filter function callings. Like the normal user can't for example call a function that would send a RAW PACKET.

BTW: Does anyone have informations about memory organisation in popular OSes? - I mean types of memory protection, paging mecganisms.

Another question is how to use gcc to compile .bin file with "org at some address" without using a standard libc, to use mine lib?
Anyone has information about building functions if we don't know how much arguments we have?


Top
  
 
 Post subject: RE:Libraries, important.
PostPosted: Tue Apr 17, 2001 11:00 pm 
>On 2001-04-17 07:13:09, cRG <[email protected]> wrote:
>Hi,
>
>Ive got a question about libraries. How calling them should looks like? call address?It's not the best idea, because I want to have a kind of protection, something that would filter function callings. Like the normal user can't for example call a function that would send a RAW PACKET.

I use call gates. Check 'em up in the Intel docs. They're quite good for this purpose :)

>BTW: Does anyone have informations about memory organisation in popular OSes? - I mean types of memory protection, paging mecganisms.

Unfortunately, no. Their almost always segmented and paged, I believe.
I don't think any modern OS uses linear memory... or full 4GB segments... but I do :)

>Another question is how to use gcc to compile .bin file with "org at some address" without using a standard libc, to use mine lib?
>Anyone has information about building functions if we don't know how much arguments we have?

That's handled by the linker, compile as usual:
gcc -c file.c

then link like so:
ldd -oformat binary file.o -o file.bin

I'm not sure about the org... I always had an asm
stub, so I used nasm's -org for that. I'm sure
ldd has a -org option too.

Jeff

>


Top
  
 
 Post subject: RE:Libraries, important.
PostPosted: Mon Apr 23, 2001 11:00 pm 
>On 2001-04-18 22:29:01, J. Weeks wrote:
>That's handled by the linker, compile as usual:
>gcc -c file.c
>
>then link like so:
>ld -oformat binary file.o -o file.bin
>
>I'm not sure about the org... I always had an asm
>stub, so I used nasm's -org for that. I'm sure
>ldd has a -org option too.

The gcc linker uses the "-Ttext" argument for the -org
option,
i.e
ld -Ttext 0 -oformat binary -o file.bin file.o

also the "-e" entry point symbol can also be used
if you are coding in some symbolic linked programs
(not sure what I'm talking about tho...)

ld -e main -o file file.o

* Something is important though that Linux have
LILO for loading that if you consult the Linux
souce code you will see the "bootsect.S" prorgam
but it is written somewhere (forgot ...) that
gcc's raw binary files don't work well for booting
(if you are making bootstrappers) because it generates
32-bit memory addressing operand and syntax (thus it
would not work when system is still in 16-bit real mode).

Ben


Top
  
 
 Post subject: RE:Libraries, important.
PostPosted: Wed May 02, 2001 11:00 pm 
>On 2001-04-18 22:29:01, J. Weeks wrote:
>>On 2001-04-17 07:13:09, cRG <[email protected]> wrote:
>>
>>Another question is how to use gcc to compile .bin file with "org at some address" without using a standard libc, to use mine lib?
>>Anyone has information about building functions if we don't know how much arguments we have?
>
>That's handled by the linker, compile as usual:
>gcc -c file.c
>
>then link like so:
>ldd -oformat binary file.o -o file.bin

You don't have to specifically link it like this to not include
the standard libraries. There is an argument that you can
pass in when compiling... something like -ffreestanding
(there should be 2 f's I think) but I'm not sure. It definately
does say in the info file under arguments though.


Top
  
 
 Post subject: RE:Libraries, important.
PostPosted: Tue Jun 19, 2001 11:00 pm 
>On 2001-04-17 07:13:09, cRG <[email protected]> wrote:
>Hi,
>
>Ive got a question about libraries. How calling them should looks like? call address?It's not the best idea, because I want to have a kind of protection, something that would filter function callings. Like the normal user can't for example call a function that would send a RAW PACKET.
I'm working on the same problem right now. I'm not finished yet, but I intend to
use paging (Give every lib or task a page table with random pages,
actually not random, but you don't know them until you get them:-)
The second part are Call gates wich point to the page table start.
I'm not sure if it is going to work. I will reply again when I am done...
>
>BTW: Does anyone have informations about memory organisation in popular OSes? - I mean types of memory protection, paging mecganisms.
>
>Another question is how to use gcc to compile .bin file with "org at some address" without using a standard libc, to use mine lib?
>Anyone has information about building functions if we don't know how much arguments we have?
>


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot], rdos and 103 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group