• 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
Can an NSString literal's bytes be moved to a different section of the executable?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can an NSString literal's bytes be moved to a different section of the executable?


  • Subject: Can an NSString literal's bytes be moved to a different section of the executable?
  • From: Jens Alfke <email@hidden>
  • Date: Wed, 24 Feb 2016 17:26:02 -0800

Is there a way to control which section of the executable a specific NSString literal goes into? I’ve tried using the ‘section’ attribute, but it has no effect:
	__attribute__((section(“__TEXT,__foo”))) static NSString* const kFoo = @“Foobar”;
The above doesn’t change where the string appears; there is no __TEXT,__foo section in the binary at all, and the string is still in the default __TEXT,__cstring section.

I’m asking because the project I work on includes a lot of logging calls, which are left in the release build so that logging can be turned on for troubleshooting in the field, but for reasons of cache locality I’d like the resulting strings (and ideally the code) not to be mixed in with the rest of the executable.

(Moving the code itself out of the way seems to be a non-starter. I’ve tried using some macro hackery to put the actual _log(…) call in a block, but adding a ‘section’ attribute to the block produces a compiler error saying that only functions and globals can have a section assigned.)

—Jens
 _______________________________________________
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: Can an NSString literal's bytes be moved to a different section of the executable?
      • From: Jean-Daniel Dupas <email@hidden>
    • Re: Can an NSString literal's bytes be moved to a different section of the executable?
      • From: Wim Lewis <email@hidden>
  • Prev by Date: Re: Xcode 7.1 Build location of legacy or unique. What does this do to the file paths within the project?
  • Next by Date: Re: Can an NSString literal's bytes be moved to a different section of the executable?
  • Previous by thread: Re: Xcode 7.1 Build location of legacy or unique. What does this do to the file paths within the project?
  • Next by thread: Re: Can an NSString literal's bytes be moved to a different section of the executable?
  • Index(es):
    • Date
    • Thread