Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > Re: Sections in...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 7 Topic 3994 of 4053
Post > Topic >>

Re: Sections in assembler forth's on un*x

by Albert van der Horst <albert@[EMAIL PROTECTED] > Apr 13, 2008 at 11:49 AM

In article
<c21633b6-2db7-494f-a2ab-3ba4eca4f229@[EMAIL PROTECTED]
>,
Robert Spykerman  <robert.spykerman@[EMAIL PROTECTED]
> wrote:
>On Apr 13, 2:21 pm, Albert van der Horst <alb...@[EMAIL PROTECTED]
>
>wrote:
>
>> Recent discussions about specification of sections and linking
>> of lina on linux and xina on OSX set me thinking and experimenting.
>>
>> I declared with emphasis that the normal sections are unusable for
Forth,
>> not being executable or not being writable.
>>
>> However, because the .text .data and .bss sections are special, they
>> are known to the linker and may be treated as special by the linker.
>> They do! It turns out that there is a linker flag, that makes the code
>> section writable. It is the -N or --omagic flag. At least it is
>> supported by the GNU loader.
>
>As you probably realize, Albert, OS X unfortunately does not use the
>standard ld linker.

I wouldn't phrase it like that. The standard linker on OS X is not
the familiar GNU loader.
When in Rome, do as the Romans do.

Is there a standard assembler for OS X?

What happens if you feed it either the .s (gas) or the .asm (nasm)
file?
I'm willing to put some work into adapting the source
to this standard assembler.

I would not abandon the standard tools, unless and before severe
difficulties are encountered.

>
>Recapping the discussions with Josh on patching privileges on the mach
>header so that the __TEXT and __DATA segments are rwx (it, of course,
>works) - I found that a bit inconvenient after a few reassembles.
>
>It turns out the linker has a 'rarely used' option -segprot
>
>http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/ld.1.html
>
>so:
>
>$ ld forth.o -segprot __TEXT rwx rwx -segprot __DATA rwx rwx -o forth

I figure the above ld is the OS X loader.
-segprot looks like the OS X equivalent of the -N option, but more
flexible.

>
>Now I believe you got both your text and .bss in one segment, under
>linux,  didn't you Albert?

I have the kernel in the text, and the buffers, stack free space etc.
in bss.
This version has the advantage that at least the section names
are familiar to BSD assemblers and linkers.

So it looks like
    $ ld forth.o -segprot __TEXT rwx rwx -segprot __BSS rwx rwx -o forth
would do the job.

>I'm still figuring out if this is possible under OS X but I don't
>think so.

If the above works in setting write and execution modes, you're
all set. And pretty straightforward after all.

I promise to help in hacking out the SAVE-SYSTEM stuff.

>
>Robert Spykerman


--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- like all pyramid schemes -- ultimately falters.
albert@[EMAIL PROTECTED]
 &=n http://home.hccnet.nl/a.w.m.van.der.horst




 7 Posts in Topic:
Sections in assembler forth's on un*x
Albert van der Horst <  2008-04-13 04:21:15 
Re: Sections in assembler forth's on un*x
Robert Spykerman <robe  2008-04-13 02:12:05 
Re: Sections in assembler forth's on un*x
Albert van der Horst <  2008-04-13 11:49:03 
Re: Sections in assembler forth's on un*x
Robert Spykerman <robe  2008-04-13 17:57:07 
Re: Sections in assembler forth's on un*x
Albert van der Horst <  2008-04-16 06:09:26 
Re: Sections in assembler forth's on un*x
Robert Spykerman <robe  2008-04-16 01:08:00 
Re: Sections in assembler forth's on un*x
Robert Spykerman <robe  2008-04-25 01:40:38 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 0:58:10 CDT 2008.