[LLVMdev] RFC: -fwritable-strings Change

Eli Friedman eli.friedman at gmail.com
Tue Jan 27 13:15:23 PST 2009


On Tue, Jan 27, 2009 at 1:00 PM, Bill Wendling <isanbard at gmail.com> wrote:
> Even with C code, we place a null string in a writable
> section, which isn't correct.

You could say that, but it's not really wrong... say you had a 10
kilobyte struct that was all null.  If you put it into a data section,
it takes up 10k in the executable (unless Darwin has some unusual data
section); it takes up no space at all in the BSS.  So naturally we'd
prefer to put it in the BSS... for a 1 byte string that doesn't really
matter, though.

The thing that seems worrisome that you're depending on choices that
could be made arbitrarily; no matter where the string is, it normally
doesn't change the semantics of the program.  In certain situations,
it could be a profitable transformation to, for example, put a string
on the stack.  If the runtime environment is depending on it being in
a specific place, you have to mark it so LLVM knows it can't do
arbitrary manipulations on it.

-Eli



More information about the llvm-dev mailing list