World: r4wp
[#Red] Red language group
older newer | first last |
GrahamC 9-May-2013 [7752] | but SL4A allows remote control of an android device :) |
DocKimbel 10-May-2013 [7753] | FYI, I'm re-arranging the Red compiler code output in order to allow the Red runtime library initialization on DLL loading. Once that done, we'll be able to produce Red shared libs (the exporting interface remains at Red/System level though). |
Gregg 10-May-2013 [7754] | Excellent Doc. That sounds great. |
james_nak 10-May-2013 [7755] | Very cool Doc. |
DocKimbel 11-May-2013 [7756x5] | I've compiled and run my first Red shared library. Use #call directive to call back Red functions from Red/System. |
Declare your Red/System exported function in a #system-global block. | |
Untested, but should work: Red [ ] #system-global [ launch: does [#call [main]] #export [launch] ] main: does [ print "Hello Red World!" ] | |
BTW, I could make the #system-global block implicit there using a Red level directive to abtract such code. | |
Hmm, would work only if no arguments are passed from the caller and no value returned to it. Red/System is still needed to marshall the values between outer world and Red datatypes. | |
Pekr 11-May-2013 [7761x2] | congrats, great work! :-) |
btw - when ELF will be finished, so that we can have JNI example without the crash when exiting app? Or was it unrelated? | |
DocKimbel 11-May-2013 [7763x2] | I've fixed the crashes on JNI demo a couple of days ago. |
The exiting crash is related to running it in a 64-bit JVM, which is not supported. | |
Gregg 11-May-2013 [7765] | Go Doc Go! |
Kaj 12-May-2013 [7766] | How about having the compilers recognise a "Type: library" field in the Red [] and Red/System [] headers, so you don't have to add the -dlib parameter to the command line? |
DocKimbel 13-May-2013 [7767] | I thought about it already as one of the ways to produce a shared lib, in some of my recent scripts there's already a `Type: 'dll` header field, but `library` is probably nicer. I will implement support for it when I'll find time as it's a minor feature. |
Kaj 13-May-2013 [7768] | Thanks |
Oldes 13-May-2013 [7769] | Hi Doc, I was messing around with the PE. Added section: [.rsrc [- #{00000000000000000004000000000000}]] in compiler (this should be just empty .rsrc, and trying to build it in PE.r using: oh/rsrc-addr: section-addr? job '.rsrc oh/rsrc-size: length? job/sections/.rsrc/2 but the address is pointing into wrong position (512B less). You probably don't know without some deeper examination, what may be the reason, do you? Btw. there should be: .rsrc #{40000040} ;-- [read initialized] at this line: https://github.com/dockimbel/Red/blob/master/red-system/formats/PE.r#L119 (the section name starts with a dot). |
DocKimbel 13-May-2013 [7770x2] | Oldes: adding .rsrc support is not trivial. I have a stashed prototype somewhere, I could push it in a new branch for you to look at and improve it. |
PE format does not require specific section names, so Red uses its own ones. | |
Oldes 13-May-2013 [7772] | be able to add just the empty .rsrc section would be a good start. |
DocKimbel 13-May-2013 [7773x5] | Let me see... |
Pushed it in new rsrc-support branch: https://github.com/dockimbel/Red/tree/rsrc-support | |
See the commit diff: https://github.com/dockimbel/Red/commit/160cf3dfa3629c63b4dc2e9465fb5337a43754b8 | |
That base should be enough for a start, the hard part now is to generate the resources tree with all the right entries ...far from easy. | |
Oh, it seems I've stopped in the middle of the coding session at ligne 381 in PE.r. | |
Oldes 13-May-2013 [7778] | Hm.. I'm not sure this will help me. I have the rsrc data (parsed from valid file), just the section's adress is not correct. |
DocKimbel 13-May-2013 [7779] | rsrc entries contain file offsets and memory addresses, if you plan to just insert a blob of data, it won't work. |
Oldes 13-May-2013 [7780x3] | So I must call some commands in the middle, instead of just data and setting pointer to it, right? |
Ok.. I will play with it even more for a while before going sleep. | |
For empty rsrc should be enough to provide: table/id-entries: 0 instead of 1 on line 377 of your commit and not adding the entry (at least that's what I see with exe containing empty rsrc). But line 369 of this commit is strange. | |
Gregg 13-May-2013 [7783x3] | Is the plan to use .res files? i.e., to have a resource compiler that the linker can include? |
*Many* years ago, I wrote a resource compiler in VB. Too long ago to have any of it left in my brain, but something might come back is .res is the target. | |
If %.res is the target. | |
Oldes 13-May-2013 [7786x2] | if the .res is just binary representation of the rsrc section, why not. But be able to append icon without need to use hacking tools would be nice as well. But we must do small steps here. At least we, who don't have Doc's brain:) |
So far adding the rswr section modifies these values: [ entry-point-addr code-base data-base ] which should be same as without rsrc in my tests, and not increasing init-data-size. | |
DocKimbel 13-May-2013 [7788x2] | Line 369: it's for getting the memory pointer for last section, but it seems it's lacking an offset for skipping that last section size. |
Gregg: no .res file, think .red file (or at least .ren). ;-) | |
Oldes 13-May-2013 [7790] | Why not .res? .res is compiled .rc |
DocKimbel 13-May-2013 [7791x2] | So, yes, we need to build a resource compiler, but the description format needs to be specified in Red format. |
Is .res binary? | |
Oldes 13-May-2013 [7793] | yes |
DocKimbel 13-May-2013 [7794] | Do you have a link for the .res format spec? |
Oldes 13-May-2013 [7795] | I believe it wil lbe just the raw content of the rsrc section. No, I don't have, but with tools like Resource Hacker you can build these from RC files which are what we don't want |
DocKimbel 13-May-2013 [7796x2] | Using .rc and Resource Hacker is fine in the meantime, until we get our own compiler. |
Looks like Gregg is a good candidate for building such compiler in the future. ;-) | |
Oldes 13-May-2013 [7798x4] | For me it would be enough to have correct PE header at this moment. |
Ok.. moving [ build-rsrc job ] after [ build-import job ] leads to expected result with the [entry-point-addr code-base data-base] values | |
no.. my mistake.. was parsing valid file instead of the one build in red with rsrc. | |
Ok, so the main problem will be, that oh/headers-size = 1024, but the pointer to code as a first section is 512. Now I must find why. | |
older newer | first last |