Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
25 May, 2013, 18:23:18 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1] 2   Go Down
  Print  
Author Topic: Ndless bFLT loader -  (Read 2221 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
tangrs
LV4 Regular (Next: 200)
****
Offline Offline

Gender: Male
Last Login: Today at 14:38:28
Date Registered: 13 July, 2011, 04:32:25
Location: Australia
Posts: 189

Topic starter
Total Post Ratings: +85

View Profile WWW
« on: 02 April, 2012, 07:33:00 »
+6

This topic will be for technical discussion for the bFLT loader.

Source code and API documentation

Let me start off this discussion.

I propose that, once bFLT becomes stable enough, it be integrated into the core Ndless code and have the SDK updated to only produce bFLT executables. However it seems that if bFLT were to be integrated into Ndless, we'll need to change some parts of the Ndless SDK itself to work in it's favor. I hope we can quickly deprecate the current way of loading binaries.

First, because bFLT stores sections in the order of .text, .data, .bss, we need to update the Ndless ldscript to reflect that. Otherwise, we run into overlapping problems. More information can be found at the bottom of the README. This is the first and easiest step.

Next: Because we do all the relocating, the startup files become redundant - even a hindrance when we deal with shared libraries. The only thing the startup files should do is branch to main since the bFLT loader will handle everything else.


Also, we need some sort of way to work out the assignment of library IDs. bFLT shared libraries work by IDs. Each library is given a unique ID and it is up to the user to ensure it is unique. Unfortunately, the number of IDs are limited and only 254 are actually available for use (255 and 0 are reserved).

I'll leave it at that for now.

@edit: is there a way of implementing _syscallvar_savedlr without relying on a linker script?
@edit2: I'm also having trouble producing a bFLT executable that doesn't rely on nspire-gcc or nspire-ld. Anyone have luck with this?
I'm having trouble writing a ldscript that will force the GOT to be at the beginning of the data section.
Got it.


Update:

The bFLT loader has a working SDK ready for developing and testing! You can now produce bFLT binaries without affecting your normal Ndless SDK!
« Last Edit: 02 April, 2012, 15:18:13 by tangrs » Logged
alberthrocks
Coder Of Tomorrow
LV8 Addict (Next: 1000)
*
Offline Offline

Last Login: 11 May, 2013, 04:49:27
Date Registered: 01 May, 2010, 16:51:27
Posts: 743

Total Post Ratings: +88

View Profile
« Reply #1 on: 02 April, 2012, 15:04:07 »
0

This is great! Cheesy I was thinking about porting bFLT a while ago, but lacked skills and time to do it. This will definitely advance Nspire development quite a bit! Cheesy

Also, do you think there's a way to change that limit?
Reading this, it says that the limit is "due to the way [he] encoded library addresses...can be changed but it requires quite a bit more effort".

I think the ID system should be changed if possible... it would be kinda weird to start assigning IDs, or having some kind of system manage IDs and such. I think having some kind of Java-style naming system, like "com.alberthrocks.myawesomelibrary", would be better. (And then call this bFLT2, Nspire edition Tongue) Just my 2 cents. Wink

Again, great work! Cheesy This will open the platform to C++ code, and make porting ten-fold easier! Cheesy

EDIT: Actually, bFLT has a version of 4.0 - I'm assuming you're using that spec, right? Also, might want to call the version 5.0 instead... Tongue
« Last Edit: 02 April, 2012, 15:13:55 by alberthrocks » Logged

Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! Sad Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. Smiley

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler for "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it Tongue)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it Tongue)
wxWabbitemu: 40% done (NEED MOAR FEATURES Tongue)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming Tongue)
tangrs
LV4 Regular (Next: 200)
****
Offline Offline

Gender: Male
Last Login: Today at 14:38:28
Date Registered: 13 July, 2011, 04:32:25
Location: Australia
Posts: 189

Topic starter
Total Post Ratings: +85

View Profile WWW
« Reply #2 on: 02 April, 2012, 15:17:05 »
0

This is great! Cheesy I was thinking about porting bFLT a while ago, but lacked skills and time to do it. This will definitely advance Nspire development quite a bit! Cheesy

Also, do you think there's a way to change that limit?
Reading this, it says that the limit is "due to the way [he] encoded library addresses...can be changed but it requires quite a bit more effort".

I think the ID system should be changed if possible... it would be kinda weird to start assigning IDs, or having some kind of system manage IDs and such. I think having some kind of Java-style naming system, like "com.alberthrocks.myawesomelibrary", would be better. (And then call this bFLT2, Nspire edition Tongue) Just my 2 cents. Wink

Again, great work! Cheesy This will open the platform to C++ code, and make porting ten-fold easier! Cheesy

There may be a way to change the ID limit but it requires modifying the linking tools and potentially breaking application support with other bFLT loaders (is this really an issue though?).

Shared libraries are implemented by having the 'ID' of the library in the high byte of the offset record in the relocations.

For example, if a offset record read 0x030000b4, it means "look for and load a library with ID of 3 and replace this offset with (the absolute address of that library image + 0xb4). That means the maximum ID number is 255 and the lowest 0 - giving us a total ID space of 256. The first and last are reserved so that only gives us 254 to work with. When you look at it this way, it becomes difficult to modify it to have more IDs because it's more of a fundamental issue.

You're right, I like the reverse domain notation too but it seems unlikely. I'm sure we can work out something though Big smile.

@edit: Yep, referring to version 4 Big smile
« Last Edit: 02 April, 2012, 15:23:02 by tangrs » Logged
Jim Bauwens
Lua! Nspire! Linux!
Editor
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 14:29:04
Date Registered: 28 February, 2011, 22:32:12
Location: Belgium
Posts: 1733


Total Post Ratings: +180

View Profile WWW
« Reply #3 on: 02 April, 2012, 16:17:48 »
0

Great work tangrs!

I think this (and the other loader stuff), deserve a news here Smiley
Logged

ExtendeD
Coder Of Tomorrow
LV8 Addict (Next: 1000)
*
Offline Offline

Gender: Male
Last Login: Today at 13:07:49
Date Registered: 02 January, 2010, 13:03:41
Location: France
Posts: 766

Total Post Ratings: +151

View Profile
« Reply #4 on: 02 April, 2012, 20:00:02 »
0

Excellent! I'll test this as soon as possible.
Logged

ndlessly - Progress and insights on Ndless
Ndless / Hackspire - Third-party TI-Nspire development
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Online Online

Gender: Male
Last Login: Today at 18:03:22
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50237


Total Post Ratings: +2615

View Profile WWW
« Reply #5 on: 02 April, 2012, 23:18:16 »
0

Great to see more development tools. Sadly I cannot understand the use of this, since I'm pretty much illiterate regarding TI-Nspire ASM and C programming, but hopefully this helps a lot.

And yeah I think this and the Elf loader or whatever it is both deserve a news, although somebody else with more knowledge on the subject might have to write it so I can move it afterward.
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
hoffa
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Male
Last Login: Today at 15:50:32
Date Registered: 28 May, 2011, 20:26:32
Posts: 302


Total Post Ratings: +115

View Profile
« Reply #6 on: 02 April, 2012, 23:37:54 »
0

At least when it comes to nSDL, having a working and stable loader would be absolutely great. It would right away open a lot of doors and remove the burden of tedious debugging. Newlib would work, giving access to a working libc and making porting a lot easier (math library and whatnot). SDL_image and other libs would work with quasi no changes and nSDL code would be considerably cleaner. Good job tangrs, this'll be a great plus.
Logged
tangrs
LV4 Regular (Next: 200)
****
Offline Offline

Gender: Male
Last Login: Today at 14:38:28
Date Registered: 13 July, 2011, 04:32:25
Location: Australia
Posts: 189

Topic starter
Total Post Ratings: +85

View Profile WWW
« Reply #7 on: 03 April, 2012, 04:53:58 »
0

Update:

Houston, we have a problem!

I've been working on getting shared libraries working and I've modified the toolchain slightly to produce shared libraries and have them link (almost!) correctly to binaries. I can also grab the address of the function of the shared library at runtime. Basically, the bFLT loader support for shared libraries is done.

But there's a problem. I noticed that the address the binary actually branches to doesn't match the address of the function. Whatever it's branching to, it's also crashing the calculator.

Turns out GCC inserts some code verneers (or bridge, if you like) that is supposed to "glue" the main binary to the shared library. This is bad for us because the address the code verneer directs us to is not relocated.

Here's a nice colorful diagram:



Basically, calling a shared library function looks like this right now:


1
2
library_call() -> gcc code verneer -> unrelocated address = crash

We want GCC to skip making a code verneer so it looks more like this:


1
2
library_call() -> library function = win

Theoretically, we could work around this by defining and using a macro like this:


1
2
3
4
5
6
7
#define DIRECT_LIB_CALL(x, args...) do { \
        typeof(x) * volatile tmp = x; \
        tmp(#args); \
    } while (0)

DIRECT_LIB_CALL(library_call);

That should bypass the code veneer but of course, this isn't very elegant nor portable.

All the code is in the shared-library-support branch of the main project.

If anyone can help me look for an option to disable the making of a code veneer (also known as code glue, code bridge etc...) when linking with shared libraries, that would be great.


Never mind, discovered a workaround (although quite annoying)
« Last Edit: 03 April, 2012, 15:14:26 by tangrs » Logged
Lionel Debroux
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Today at 16:14:00
Date Registered: 17 December, 2009, 09:37:25
Location: France
Posts: 1854

Total Post Ratings: +208

View Profile WWW
« Reply #8 on: 03 April, 2012, 07:24:38 »
0

Looks like the PLT code ( http://stackoverflow.com/questions/5469274/what-does-plt-mean-here and others)...
Indeed, either we don't want that code at all, or the Ndless loader needs to be able to resolve this kind of stuff Sad

EDIT: pages such as http://www.acsu.buffalo.edu/~charngda/elf.html or http://fossies.org/unix/misc/glibc-2.15.tar.gz:a/glibc-2.15/FAQ might contain some useful information.
« Last Edit: 03 April, 2012, 08:46:24 by Lionel Debroux » Logged

Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.
tangrs
LV4 Regular (Next: 200)
****
Offline Offline

Gender: Male
Last Login: Today at 14:38:28
Date Registered: 13 July, 2011, 04:32:25
Location: Australia
Posts: 189

Topic starter
Total Post Ratings: +85

View Profile WWW
« Reply #9 on: 03 April, 2012, 15:19:37 »
+1

Update!

Surprise!

Shared library support is now stable!

Now, we need to work out a solution with the library ID problem. How do we allocate 254 IDs to the many people wishing to develop a library? Perhaps reserve IDs 3-10 for Ndless, IDs 10-250 for allocating to projects that are big enough and IDs 250-254 for private use? What do you guys think?

Apart from that, all that the bFLT loader needs now is a little polishing and integration into Ndless Smiley

(Don't you just love the look of all those "PASS"es? Tongue)

« Last Edit: 03 April, 2012, 15:23:38 by tangrs » Logged
Jim Bauwens
Lua! Nspire! Linux!
Editor
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 14:29:04
Date Registered: 28 February, 2011, 22:32:12
Location: Belgium
Posts: 1733


Total Post Ratings: +180

View Profile WWW
« Reply #10 on: 03 April, 2012, 17:23:03 »
0

Very nice Cheesy
Logged

DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Online Online

Gender: Male
Last Login: Today at 18:03:22
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50237


Total Post Ratings: +2615

View Profile WWW
« Reply #11 on: 04 April, 2012, 05:54:15 »
0

At least when it comes to nSDL, having a working and stable loader would be absolutely great. It would right away open a lot of doors and remove the burden of tedious debugging. Newlib would work, giving access to a working libc and making porting a lot easier (math library and whatnot). SDL_image and other libs would work with quasi no changes and nSDL code would be considerably cleaner. Good job tangrs, this'll be a great plus.

I assume nSDL is kinda like shells on the 84+ (MirageOS, Ion, etc), coming with routines to make development easier?
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
tangrs
LV4 Regular (Next: 200)
****
Offline Offline

Gender: Male
Last Login: Today at 14:38:28
Date Registered: 13 July, 2011, 04:32:25
Location: Australia
Posts: 189

Topic starter
Total Post Ratings: +85

View Profile WWW
« Reply #12 on: 04 April, 2012, 09:31:38 »
0

Update: Committed some experimental Ndless patches for bFLT to the repo. The patches integrate bFLT loading directly into Ndless itself.
« Last Edit: 04 April, 2012, 09:32:03 by tangrs » Logged
Lionel Debroux
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Today at 16:14:00
Date Registered: 17 December, 2009, 09:37:25
Location: France
Posts: 1854

Total Post Ratings: +208

View Profile WWW
« Reply #13 on: 04 April, 2012, 09:39:51 »
0

Great, this will speed up testing and integration further Smiley

BTW: you should update your local copy, and the patch, with Ndless 3.1 beta SVN r568 (or whatever the latest current version is). fixprint, for instance, requires r568 or later.
Logged

Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.
tangrs
LV4 Regular (Next: 200)
****
Offline Offline

Gender: Male
Last Login: Today at 14:38:28
Date Registered: 13 July, 2011, 04:32:25
Location: Australia
Posts: 189

Topic starter
Total Post Ratings: +85

View Profile WWW
« Reply #14 on: 04 April, 2012, 09:52:05 »
0

I think I'm on latest revision (r573 was it?). I think there was a typo in the file name. Let me fix it.
Logged
Pages: [1] 2   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.294 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.