OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:05 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: GCC Cross Compiler Tutorial Suggestions
PostPosted: Tue Sep 02, 2014 4:49 pm 
Offline
Member
Member
User avatar

Joined: Wed Jul 30, 2014 1:05 am
Posts: 153
This is just a new trick I discovered that some people might find useful, which isn't particularly limited to building the gcc, but it is very interesting.


If you take an object file and dump the de-mangled symbols from it with nm
Code:
nm -C obj.exe >> obj.txt
you'll end up with a list of symbols like:
Code:
00403004 D mystring

You can actually use those values in your application:
Code:
#define ptr2val(type, ptr) *((type*)(ptr))

printf(ptr2val(char *, 0x00403004));


I'm thinking about writing a branch of gettext that adds new instructions:
Code:
ptrid untranslatedVarName
ptrval translatedVarName
then extracts the symbols from the applications object files. This would largely benefit applications on embedded systems where a file system isn't available, or where having file names embedded into the application takes too much space.


Top
 Profile  
 
 Post subject: Re: GCC Cross Compiler Tutorial Suggestions
PostPosted: Tue Sep 02, 2014 5:40 pm 
Offline
Member
Member
User avatar

Joined: Wed Mar 21, 2012 3:01 pm
Posts: 930
wat.


Top
 Profile  
 
 Post subject: Re: GCC Cross Compiler Tutorial Suggestions
PostPosted: Tue Sep 02, 2014 5:57 pm 
Offline

Joined: Tue Jun 05, 2012 8:21 pm
Posts: 6
DaemonR wrote:
...I'm thinking about writing a branch of gettext that adds new instructions:
Code:
ptrid untranslatedVarName
ptrval translatedVarName
then extracts the symbols from the applications object files. This would largely benefit applications on embedded systems where a file system isn't available, or where having file names embedded into the application takes too much space.


Most embedded images once deployed will have extensive debug maps and symbols created which can be used with a debugger.


Top
 Profile  
 
 Post subject: Re: GCC Cross Compiler Tutorial Suggestions
PostPosted: Tue Sep 02, 2014 7:40 pm 
Offline
Member
Member
User avatar

Joined: Wed Jul 30, 2014 1:05 am
Posts: 153
GhostlyDeath wrote:
Most embedded images once deployed will have extensive debug maps and symbols created which can be used with a debugger.


It's not always the case though. The system I had in my mind while thinking about this only has about 4MiB of ram and 64MiB of rom. Making an application with a decent amount of content requires stripping the symbols and using overlays. Gettext just isn't a reliable method of localization for it.


Top
 Profile  
 
 Post subject: Re: DaemonR's assorted tricks
PostPosted: Wed Sep 03, 2014 7:41 pm 
Offline
Member
Member
User avatar

Joined: Wed Jul 30, 2014 1:05 am
Posts: 153
This is just something I realized here recently, if you're using MinGW on Windows, DO NOT use the gui installer assistant!!

The MinGW installer sets up the package like:
Code:
MinGW = C:/MinGW
MSYS = C:/MinGW/msys/1.0
But this is @$$-backwards. All of the shell scripts are configured to work like
Code:
MinGW = C:/MSYS/mingw
MSYS=C:/MSYS

If you don't set it up this way you'll be thrown for a loop when you try to set up a more complex autotools project with gettext or custom m4 scripts because nearly every single script will be pointing at the wrong directory (including /etc/profile, which is why many users have to manually add C:/MinGW/bin to their environment path)


Instead, do it manually by following the directions on this page (MSYS) and this page (MinGW).

(Note: MSYS Core 1.0.11 is a misdirected link, it's actually here)

--------

Some extra installation notes for when installing MinGW libs from the SourceForge repository:

  • The gettext, automake, autoconf, and libtool binaries you want to install are in the MinGW/Base and MinGW/Extension directories. These you'll want to install into your /mingw directory.
  • You'll need the gettext dev package for gettextize
  • You'll want to install all versions of automake and autoconf and their wrappers
  • The bison and flex you want are in MSYS/Extensions. These you'll want to install into your / directory. You may want wget here as well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 22 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group