08-27-2012, 09:31 AM | #16 | |
Going Viral
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Quote:
Yeah, I know that is obvious, but this morning it seems we keep getting bit by the obvious. Doing the "insmod" should have created the directory. It did not, so assume == code missing from the /proc filesystem to do that. The way you found to make it work, is the way it has to be done in this special case of the configuration having CONFIG_BINFMT == not set. insmod mkdir mount The last two are a replacement for the /proc system code that got conditionalized away. The 'net write-ups all presume that CONFIG_BINFMT == M was set in the kernel build. Last edited by knc1; 08-27-2012 at 09:34 AM. |
|
08-27-2012, 09:36 AM | #17 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
Okay that appears to be a symbolic link - when it exists ?
Would that be when the kernel does include support for binfmt_misc? ta. EDIT: Ah yeah! Thanks for that. I'm not going mad. maybe I can get us a mount.binfmt_misc if I hunt around in the medium term, but that would still *possibly* mean affecting the /sbin directory directly and that is a no IMHO. okay well happy day! I'll get back on with the implementation bit : ) Last edited by twobob; 08-27-2012 at 09:39 AM. Reason: KNC1 confirmed the suspisions |
08-27-2012, 09:43 AM | #18 |
Going Viral
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
That seems to be patching the Debian/Ubuntu automation.
You can do the same with a standard tcc and without patching the automation: http://hg.minimodding.com/repos/aufs...v/6c33d1113b9c |
08-27-2012, 09:46 AM | #19 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
Just for giggles.
root@kindle:root> echo ":luajit:M::\x1b\x4c\x4a::/usr/bin/luajit:" > /mnt/us/proc/sys/fs/binfmt_misc/register root@kindle:root> cat /mnt/us/proc/sys/fs/binfmt_misc/register :luajit:M::\x1b\x4c\x4a::/usr/bin/luajit: So it's not broken being on FAT it would seem... onward. EDIT: There IS NO LUAJIT there, I'm just testing writing a single record... Last edited by twobob; 08-27-2012 at 09:57 AM. Reason: MAKE IT OBVIOUS |
08-27-2012, 09:49 AM | #20 | |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
Quote:
|
|
08-27-2012, 09:58 AM | #21 |
Going Viral
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
apt-get install tcc
should be all you need for your dev system to have "C" scripting. The Debian/Ubuntu helper stuff for setting up binfmt_misc on your dev system is in the text of the repository file linked to above. Hmm... Now I am getting lost - Where you automating "C" scripting on the K3? Naw... He wasn't doing that, we both know the K3 doesn't have Debian/Ubuntu automation. Will return when my mind clears up a bit from these meds. |
08-27-2012, 10:01 AM | #22 | |
Going Viral
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Quote:
That will tell you if the system is working. Example of that testing (for lua): http://hg.minimodding.com/repos/aufs...v/0d73a71ae86f |
|
08-27-2012, 10:14 AM | #23 | |
Going Viral
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Quote:
|
|
08-27-2012, 10:38 AM | #24 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
hmm. call me stupid but I cant find the path the the lua thingy...
root@kindle:/> find / -name jit* root@kindle:/> find / -name *jit root@kindle:/> find / -name *5.1* root@kindle:/> find / -name *lua* or *lua or lua* all are not helpful as were not my gurgle searches - ho hum - moving on I will try Perl then |
08-27-2012, 11:25 AM | #25 | |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
Let's try to figure out how to do one for ourselves...
Always a good exercise root@kindle:/> readelf -h /mnt/us/usr/bin/perl Quote:
Spoiler:
so given that information and the reference from kernel org: Code:
To actually register a new binary type, you have to set up a string looking like :name:type:offset:magic:mask:interpreter:flags (where you can choose the ':' upon your needs) and echo it to [/mnt/us]/proc/sys/fs/binfmt_misc/register. Here is what the fields mean: - 'name' is an identifier string. A new /proc file will be created with this name below /proc/sys/fs/binfmt_misc - 'type' is the type of recognition. Give 'M' for magic and 'E' for extension. - 'offset' is the offset of the magic/mask in the file, counted in bytes. This defaults to 0 if you omit it (i.e. you write ':name:type::magic...') - 'magic' is the byte sequence binfmt_misc is matching for. The magic string may contain hex-encoded characters like \x0a or \xA4. In a shell environment you will have to write \\x0a to prevent the shell from eating your \. If you chose filename extension matching, this is the extension to be recognised (without the '.', the \x0a specials are not allowed). Extension matching is case sensitive! - 'mask' is an (optional, defaults to all 0xff) mask. You can mask out some bits from matching by supplying a string like magic and as long as magic. The mask is anded with the byte sequence of the file. - 'interpreter' is the program that should be invoked with the binary as first argument (specify the full path) - 'flags' is an optional field that controls several aspects of the invocation of the interpreter. Code:
echo ':perl:M::\x7fELF\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00::/mnt/us/usr/bin/perl:' > /mnt/us/proc/sys/fs/binfmt_misc/register Code:
(or echo ':perl:E::pl::/mnt/us/usr/bin/perl:'>blah) #!/mnt/us/usr/bin/perl print "Hello world!\n"; save it. root@kindle:script> ./hello.pl Hello world! Seems to be a worker? great. Next step... getting this to help us load our 300 odd applications from Buildroot without having to write a script for each. TBC Last edited by twobob; 08-27-2012 at 11:28 AM. Reason: corrected path |
|
08-27-2012, 11:54 AM | #26 | |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
So Anyways...
To the thrust of this lot: Quote:
TBC... |
|
08-27-2012, 11:56 AM | #27 | |
Going Viral
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Quote:
You can't be sure that it is working with that perl script. Remove the first line (the #!/....), it binfmt_misc fails, the normal loader search will find and use that line. Does (or can) Perl produce "compiled" executables? in that case, you want to do "magic" matching against whatever identifier the Perl compiler puts in its output files. **not** the magic identifier of perl itself. If Perl can not produce "pre-compiled" scripts - then you need to do one of two things: Either "extension" matching, such as you have done above OR Put a byte string (printable characters are ok) somewhere in the source where you can test for it with the "magic" matching. (Like the earlier tcc example required the magic string "BINFMTTC" at the start of the first line. It is just a fixed identifier, with right combination of offset, string, and mask it could be: "lab126 sucks" starting at byte 255 of the source. - - - - Hindsight: We (of I) got onto this over the problem that the current emulator (and the current tcc built for the Kindle in our threads) expect to have the uClibc system loader and system libraries but the Kindles are glibc systems. So the idea was to put the "interpreter" string (ld-uclibc.so or whatever it is - readelf will report it) as the "magic" to be tested for and use a "supporting script" to use the manual invocation of the loader (like you did with the ld-linux.so loader). Only speed bump - our uClibc build wasn't configured so that the loader could be called manually. The reasons that I need to provide new or re-built emulator images is getting too long to even remember. Now another problem that we might be able to "fix" with this - - - executables built against glibc of a version not supported on the Kindle. **IF** we can identify them by some constant sequence of bytes in their header (or write our own ID bytes in the headers with objcopy). Sorry that I can't be of more specific help - It will be at least a week before the Dr. lets me have the use of my mind back. |
|
08-27-2012, 12:02 PM | #28 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
erm. so I know I'm slow but do you mean?
23:21:6c:64:2e:33 which is #!ld.3 in hex? |
08-27-2012, 12:10 PM | #29 |
Going Viral
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
I just tossed that out as a "place holder example" -
But yeah, we should be looking for something different about executibles built for the old glibc and ones built for the new glibc. If readelf does not give enough information, objdump will. If no usable differences can be found in the elf header of old vs. new - Then we will have to "mark" them ourselves (find an un-used bit/byte and set to a value that equals == Kindle Hack). Sorry I can't be of more help, I am months behind in catching up with your work. |
08-27-2012, 01:06 PM | #30 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
meh be right. I get it now. the final magic not the called exe.
understood. well I'll have to think how that applies then and get back on this. either way it works. |
Tags |
binfmt_misc, kindle3, tools |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
iLiad My iliad porting adventures! | pwarren | iRex Developer's Corner | 3 | 05-26-2009 09:37 PM |
The adventures of your eReader | Kirari | Lounge | 13 | 05-15-2009 12:32 PM |
Adventures in Thailand | THJahar | HanLin eBook | 1 | 03-01-2007 08:38 AM |
Adventures of a tourist | Quantum | Sony Reader | 8 | 11-06-2006 05:58 PM |