This is a follow up of D21662.
The main issue here is that the "thumb" flag wasn't set for some of these
sections, making MSVC's link.exe fails to correctly relocate code
against the symbols inside these sections. link.exe could fail for
instance with the "fixup is not aligned for target 'XX'" error. If
linking doesn't fail, the relocation process goes wrong in the end and
invalid code is generated by the linker.
To reproduce the error, one can compile this file as a static library:
#include <stdio.h>
void test(const char* s)
{
const void* ptr = &snprintf;
printf("%s: %p\n", s, ptr);
}
and then create a dynamic library that links against this static library
(which calls the 'test' function). A visual studio project can be
provided for people interested.
The same thing applies to lld ;-). This is not link.exe specific.
The flag isn't "basically" telling the linker, it is exactly telling the linker that. This is a carry over from the older ARM support: thumb(-1) was 16-bit instructions, and the IMAGE_SCN_MEM_16BIT indicates that the text is 16-bit instructions, aka thumb mode.
I don't think that the comment adds anything of value.