Page 1 of 1

Libraries, important.

Posted: 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?

RE:Libraries, important.

Posted: Tue Apr 17, 2001 11:00 pm
by J. Weeks
>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

>

RE:Libraries, important.

Posted: Mon Apr 23, 2001 11:00 pm
by Ben Hsu
>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

RE:Libraries, important.

Posted: Wed May 02, 2001 11:00 pm
by Nick
>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.

RE:Libraries, important.

Posted: Tue Jun 19, 2001 11:00 pm
by Guest
>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?
>