• 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: 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]

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


  • Subject: Re: Can an NSString literal's bytes be moved to a different section of the executable?
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 25 Feb 2016 09:39:02 -0800


On Feb 24, 2016, at 6:15 PM, Wim Lewis <email@hidden> wrote:

You can place a C string into a specific section using syntax like this:

   static __attribute__((section("__TEXT,foo"))) const char foo_var[] = "Foo, forsooth.”;

I did try using that instead. The problem is that these strings are used at the call-site as format strings (for the logged message), and I run into trouble with the `format` attribute on the logging function — I can’t use the `__NSString__` style because the parameter isn’t an NSString anymore, but I can’t use the `__printf__` style because that doesn’t allow `%@`. :(

There's also an __attribute__((cold)), which is documented to be useful for situations like this, including basic-block reordering, but I don't know if the Xcode toolchain does anything with it.

It’s not in Clang’s list of attributes, although it is in GCC’s, so I assume Clang doesn’t support it.
http://clang.llvm.org/docs/AttributeReference.html
https://gcc.gnu.org/onlinedocs/gcc-4.3.5/gcc/Function-Attributes.html

—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

References: 
 >Can an NSString literal's bytes be moved to a different section of the executable? (From: Jens Alfke <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: Missing vars in Swift-ified interface
  • Next by Date: How to fix "misuse of 'nonnull'" warnings in Xcode 7.3?
  • Previous by thread: Re: Can an NSString literal's bytes be moved to a different section of the executable?
  • Next by thread: Re: Can an NSString literal's bytes be moved to a different section of the executable?
  • Index(es):
    • Date
    • Thread