On Tue, Feb 18, 2025 at 11:51:41AM -0800, Kees Cook wrote: > On Fri, Feb 14, 2025 at 11:21:07AM +0100, Jakub Jelinek wrote: > > On Thu, Feb 13, 2025 at 02:10:25PM +0100, Jakub Jelinek wrote: > > > Kees, are you submitting this under assignment to FSF (maybe the Google > > > one > > > if it has one) or DCO? See https://gcc.gnu.org/contribute.html#legal > > > for details. If DCO, can you add your Signed-off-by: tag for it? > > > > > > So far lightly tested, ok for trunk if it passes bootstrap/regtest? > > > > Bootstrapped/regtested on x86_64-linux and i686-linux successfully. > > Thank you for getting this done! I really appreciate having this > available. I'll give it a spin. :)
Sorry this took me so long. I finally tested this and while it does allow setting nonstring on multi-dim char arrays, it looks like the initializer check is still broken: $ cat multi.c const char table_sigs[][4] __attribute__((nonstring)) = { "BERT", "BGRT", "CPEP", "ECDT" }; $ gcc -o multi.o -c multi.c -O2 -Wall -Wunterminated-string-initialization multi.c:2:9: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (5 chars into 4 available) [-Wunterminated-string-initialization] 2 | "BERT", "BGRT", "CPEP", "ECDT" | ^~~~~~ multi.c:2:17: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (5 chars into 4 available) [-Wunterminated-string-initialization] 2 | "BERT", "BGRT", "CPEP", "ECDT" | ^~~~~~ ... It looks like get_attr_nonstring_decl() still isn't correctly finding the attribute. (It looks like multi-dimensional static initializers tests that drop the NUL are missing in commit ab714e60870d.) And to answer your earlier question about Linux's use, while we have the __nonstring macro for applying the attribute, I intend to add __nonstring_array that is version-checked against GCC 15. -Kees -- Kees Cook