• 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: "Kyle Sluder" <email@hidden>
  • Date: Mon, 30 Jul 2007 09:57:41 -0400

If it doesn't matter where these strings start, and these strings
don't need to be accessed by your code, you could locate them in their
own section using attributes.

http://www.ohse.de/uwe/articles/gcc-attributes.html#func-section



On 7/30/07, Martin Crane <email@hidden> 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!
>
> Regards,
>
> Martin Crane
> Macintosh Software Engineer
> http://www.vicomsoft.com
> Policing For Productivity
> ________________________________________________________
> Vicomsoft is a dynamic market leader in Content Filtering, Internet
> Connectivity and Firewall Software, with an award-winning portfolio
> specifically designed for Mac OS X and Windows
> ________________________________________________________
>
>
>  _______________________________________________
> 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
>
 _______________________________________________
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

  • Follow-Ups:
    • Re: Control initialised data layout?
      • From: Martin Crane <email@hidden>
References: 
 >Control initialised data layout? (From: Martin Crane <email@hidden>)

  • Prev by Date: Control initialised data layout?
  • Next by Date: Re: Control initialised data layout?
  • Previous by thread: Control initialised data layout?
  • Next by thread: Re: Control initialised data layout?
  • Index(es):
    • Date
    • Thread