Can an NSString literal's bytes be moved to a different section of the executable?
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