• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Control initialised data layout?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Control initialised data layout?


  • Subject: Re: Control initialised data layout?
  • From: Chris Suter <email@hidden>
  • Date: Wed, 1 Aug 2007 18:30:51 +1000


On 30/07/2007, at 10:58 PM, Martin Crane wrote:

Hi,

Is there a way to control the layout of the initialized data segment of a MACH-O binary?

The problem I'm having is that some code I am porting expects a static char array, followed by a char array to be in the order defined in the source code, but this isn't the case when compiled with Xcode. I know it sounds horrible (it is!), but the binary is scanned by an external app for copy protection purposes and these two buffers must be laid out correctly in order for it to work. I can't change it... and needless to say, the CodeWarrior (OS 9) and Windows versions don't have this problem.

So, to demonstrate, in the code I have (example, not real!):

static unsigned char gBuffer1[8] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};
unsigned char gBuffer2[8] = { 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'};

and the external app expects to see "abcdefghhgfedcba" in the data area of the binary.

Unfortunately, the resultant layout from an Xcode compile gives a binary with this:

"hgfedcba<lots of strings and other data here>abcdefgh"

For what it's worth, this is a Carbon app.

Any suggestions highly welcome!

As a temporary workaround, I believe passing -fno-common to gcc will put them together although I don't know how reliable that would be. Some other compilers I've encountered don't have common sections by default so it might be an option you want anyway if the code was written with that in mind.

Obviously, this isn't the proper fix as others have suggested.

- Chris

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re[2]: Control initialised data layout?
  • Next by Date: Re: Xcode-users Digest, Vol 4, Issue 369
  • Previous by thread: Re: Control initialised data layout?
  • Next by thread: Re: Xcode-users Digest, Vol 4, Issue 369
  • Index(es):
    • Date
    • Thread