r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Red] Red language group

Kaj
15-Mar-2011
[478]
I don't mind the current limitations much if I know they will be 
fixed. I like to push the boundaries :-)
Dockimbel
16-Mar-2011
[479]
Cross-compilation is now supported from the command-line: do/args 
%rsc.r "[-vvvv] [-f PE|ELF] %path/source.reds"
Kaj
16-Mar-2011
[480]
That's a really cool ability. It will turn some heads
Kaj
17-Mar-2011
[481x8]
I published a new version of the 0MQ binding:
http://rebol.esperconsultancy.nl/extensions/0MQ/ZeroMQ-binding.reds
This one is adapted for the latest Red. Since the basic runtime is 
now included by Red, it is removed from the binding
The send/receive functions have been changed from string to binary, 
so they can handle generic data
If you want to send data to Red from R3 or R2 using the Hello World 
example, you need to add a zero byte to the data, though, C style, 
because the example still expects string data
The test executables should now run on Windows, instead of just WINE:
http://rebol.esperconsultancy.nl/extensions/0MQ/server.exe
http://rebol.esperconsultancy.nl/extensions/0MQ/client.exe
jocko
17-Mar-2011
[489]
works fine under windows xp !
Kaj
17-Mar-2011
[490]
Cool, thanks for reporting
Gregg
18-Mar-2011
[491]
Works here under XP x64! Wow. Just...wow.
Kaj
18-Mar-2011
[492x4]
X64. :-) It's 32 bits, but good to know there are no compatibility 
problems
The current ELF backend format doesn't satisfy Syllable's loader 
yet (Syllable Desktop has its own in-kernel ELF loader)
When I compile the tests on Linux and try to run them on Syllable, 
I get this in the kernel log:
0:bash::bash : Error: load_image() Invalid section size 0, expected 
40

0:bash::bash : ERROR : execve(./empty) failed. Too late to recover, 
will exit
Dockimbel
18-Mar-2011
[496]
Do you have a readelf command-line utiliy on Syllable?
Kaj
18-Mar-2011
[497]
Yep, the standard GNU BinUtils one
Dockimbel
18-Mar-2011
[498x2]
Can you paste me here the result of : readelf -l empty
(just the program header entries)
Kaj
18-Mar-2011
[500]
I don't think it would be any different than on Linux, but I will
Dockimbel
18-Mar-2011
[501]
Should be 2 lines starting with LOAD.
Kaj
18-Mar-2011
[502]
OK
Dockimbel
18-Mar-2011
[503]
Also, do you know if Syllable requires a "section headers" part in 
executable binaries? (it's optional in ELF specifications)
Kaj
18-Mar-2011
[504x3]
[[kaj-:-syllable]:~/Red]readelf -l empty

                                                                                                                                                                                                        
Elf file type is EXEC (Executable file)
Entry point 0x8048074
There are 2 program headers, starting at offset 52

                                                                                                                                                                                                        
Program Headers:

  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg 
  Align

  LOAD           0x000000 0x08048000 0x08048000 0x00184 0x00184 R E 
  0x1000

  LOAD           0x000184 0x08048184 0x08048184 0x00032 0x00032 RW 
   0x1000
[[kaj-:-syllable]:~/Red]
Indeed, exactly the same as on Linux, as it's the same executable, 
and the same readelf
I have to mention that Syllable does something odd by compiling all 
its own programs as shared libraries, so it could also be a problem 
in our loader that wasn't hit before
Dockimbel
18-Mar-2011
[507x2]
Seems good, sizes are specified, 0x32 (40) for the 2nd segment. Don't 
know what could cause the issue for the image loader, maybe the lack 
of section headers?
oops, 0x32 = 50
Kaj
18-Mar-2011
[509]
I don't know, I'll have to dive into our loader. It's much like Red: 
the minimum we needed over time to get things working :-)
Dockimbel
18-Mar-2011
[510]
AFAIK, shared libraries on Linux have special requirements, like 
for the code, it must be compiled in PIC mode (Postion Independent 
Code). Red/System doesn't support that mode.
Kaj
18-Mar-2011
[511]
Yes, I expect it not to work once loaded, but it doesn't even load 
yet
Dockimbel
18-Mar-2011
[512]
A good opportunity to learn more about Linux kernel hacking. :-)
Kaj
18-Mar-2011
[513x2]
Not really, this is the Syllable kernel :-)
We determined that the shared library trick isn't even necessary, 
so we have a backburner plan to change it. So I hope it will be possible 
to get regular executables to run
Dockimbel
18-Mar-2011
[515]
Btw, PIC mode will have to be supported at some point of Red evolution 
in order to be able to build dynamic libraries for Linux (don't know 
for OS X).
Kaj
18-Mar-2011
[516]
Yep, that will be another impressive addition
Dockimbel
18-Mar-2011
[517]
DLL generation support could be added for Windows without too much 
effort (just by extending the PE.r code), but for Linux, it requires 
both work at the linker and at the compiler level for PIC support.
Kaj
18-Mar-2011
[518x2]
Here's our loader:
http://syllable.cvs.sourceforge.net/viewvc/syllable/syllable/system/sys/kernel/kernel/elf.c?view=markup
Dockimbel
18-Mar-2011
[520x2]
Code looks somehow cleaner and easier to read than the linux loader. 
:-)
Ok it seems it relies on section headers rather than program headers: 

if ( sElfHdr.e_nSecHdrSize != sizeof( Elf32_SectionHeader_s ) )
{

    printk( "Error: load_image() Invalid section size %d, expected %d\n", 
    sElfHdr.e_nSecHdrSize, sizeof( Elf32_SectionHeader_s ) );
    nError = -EINVAL;
    goto error;
}
Andreas
18-Mar-2011
[522]
i think we can add a basic shdr table rather quickly
Dockimbel
18-Mar-2011
[523x2]
nSecHdrSize is at 0 in Red's emitter.
Andreas: yes, it's not a big deal...seems you're volunteering? :-)
Andreas
18-Mar-2011
[525]
i'll at least have a look or two :)
Kaj
18-Mar-2011
[526x2]
That would be cool
readelf gave me the impression that section and program headers are 
the same