Article View: comp.sys.mac.programmer.codewarrior
Article #1132Re: Need help with prebinding in mach-O X app and CW 7
From: meeroh
Date: Thu, 11 Oct 2001 20:17
Date: Thu, 11 Oct 2001 20:17
74 lines
4859 bytes
4859 bytes
In article <B7EB45E7.1C11%petrock99@hotmail.com>, petrock99 <petrock99@hotmail.com> wrote: >>> I was handed a source tree, the most horrid makefile I have ever seen >>> and was told to get the code to compile and run with CW Pro 7 (its a >>> mach-O >>> app originally compiled with gcc). I have got it all compiled and it >>> actually runs, but I am hitting a snag. Apparently the code assumes that >>> other memory has been prebound by the linker (LD command in the makefile) >>> to specific memory addresses. I know which how much memory needs to be >>> prebound, but I just don't know how to prebind it... I'm also not that >>> familiar with prebinding in general... >>> >>> How do I prebind some memory into specific memory space in CW 7? Is >>> there a postlinker I can use? Prelinker? Do I have to write some >>> custom plug-in to do this (hope not)? >>> >>> I can't change the code btw (if I can help it), only my CW project cause >>> they still want this thing to compile in gcc and run. >>> >>> Thanks for any help... >> >> Traditionally Macs have used position independent code, that is loaded >> by the loader at whatever address the loader feels like. There is no way >> to control what address your program is loaded at. However, one of the >> system calls in Mac OS X is "mmap". Open a Terminal window and type: >> >> man mmap >> >> as you'll see, it takes a piece of the virtual memory address space and >> maps it to a specific disk file. I've used this in the past to implement >> a malloc arena so that I could get multiple threads on multiple CPUs to >> all see the same graph data structure, and have the data-graph be >> persistent: days later, a thread could mmap() the universe file, and >> start right up. No need to read the entire data structure from a file >> and rebuild the spider-web of pointers: one mmap(), and the VM system >> does my file i/o for me, with no i/o routines to debug. > >Thanks for the reply. The traditional macOS would not support what I am >trying to do. This I know. OS X, on the other hand, does support this. It >inherits it from NeXT. > >I don't think mmap is going to be a good long term solution to this problem. >The memory I am mapping has the potential to be huge, and I don't think >anyone is going to like have some huge file laying around when they run my >app. Plus the disk access time would seriously slow things down... > >I know this can be done. gcc does it perfectly with -segaddr, -ld linker >commands (they are described in the man pages), so I assumed Codewarrior >would have a similar functionality. > >Basically what this is supposed to end up doing is, when my app gets loaded >into RAM, the loader will get commands to pre-define chunks of memory in my >apps memory space in locations that I choose. So when my app runs it has it >hard coded that this memory is there and that it can access it etc. Its >hard for me to completely explain it without giving out some proprietary >info, but it has to be done this way. > >I'm sorry to say that if I can't find a solution to this problem, then this >project will get scrapped and my group will have to continue to use gcc, gdb >and MPW.... That would suck... I can't stand gdb or MPW... ThatοΏ½s why I >started this project to get things running on CodeWarrior... You should look at the Mach Kernel APIs, in that case. You can use them to control your memory allocation and mapping. Start at <http://www-2.cs.cmu.edu/afs/cs/project/mach/public/www/doc/osf.html> hth meeroh -- You can get random signatures if you put text files into a folder called "Random Signatures" in your Preferences folder.
Technical Details
Message-ID:
<macdev-2DD265.16174911102001@senator-bedfellow.mit.edu>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!howland.erols.net!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!dreaderd!not-for-mailReferences:
<B7E8FE67.1A73%petrock99@hotmail.com> <B7EB45E7.1C11%petrock99@hotmail.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 101ec9,ef15befb73ed7c3b X-Google-Attributes: gid101ec9,public X-Google-Thread: 10bcce,5c1be2137b27795e X-Google-Attributes: gid10bcce,public X-Google-Thread: f635e,ef15befb73ed7c3b X-Google-Attributes: gidf635e,public X-Google-ArrivalTime: 2001-10-11 13:17:52 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!howland.erols.net!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!dreaderd!not-for-mail From: meeroh <macdev@meeroh.org> Newsgroups: comp.sys.mac.programmer.codewarrior,comp.sys.mac.programmer.help,codewarrior.mac Mail-Copies-To: poster Subject: Re: Need help with prebinding in mach-O X app and CW 7 Organization: meeroh.org References: <B7E8FE67.1A73%petrock99@hotmail.com> <B7EB45E7.1C11%petrock99@hotmail.com> User-Agent: MT-NewsWatcher/3.1 (PPC) Date: Thu, 11 Oct 2001 16:17:49 -0400 Message-ID: <macdev-2DD265.16174911102001@senator-bedfellow.mit.edu> Lines: 74 NNTP-Posting-Host: DONT-GRIEVE-ADMIRAL.MIT.EDU X-Trace: 1002831469 senator-bedfellow.mit.edu 1926 18.18.1.86