https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108849
Bug ID: 108849 Summary: __declspec(code_seg("segname")) does not work Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: pali at kernel dot org Target Milestone: --- Originally reported on: https://sourceware.org/bugzilla/show_bug.cgi?id=30005 GCC/LD does not support __declspec(code_seg("segname")) declarator for specifying name of PE/COFF segment name. Instead GCC/LD supports different and custom syntax __declspec(section("segname")) incompatible with other compilers, like MSVC. Please add support for de-facto standard "code_seg" declarator into the PE/COFF __declspec keyword and not custom declarator. It does not bring any value, just make code incompatible with gcc. Test case on Debian sid: $ x86_64-w64-mingw32-ld -v GNU ld (GNU Binutils) 2.39.90.20230110 $ $ x86_64-w64-mingw32-gcc -v Using built-in specs. COLLECT_GCC=x86_64-w64-mingw32-gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/12-win32/lto-wrapper Target: x86_64-w64-mingw32 Configured with: ../../src/configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --disable-option-checking --disable-silent-rules --libdir='/usr/lib/x86_64-linux-gnu' --libexecdir='/usr/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-shared --enable-static --disable-multilib --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --libdir=/usr/lib --enable-libstdcxx-time=yes --with-tune=generic --with-headers --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++,ada --enable-lto --enable-threads=win32 --program-suffix=-win32 --program-prefix=x86_64-w64-mingw32- --target=x86_64-w64-mingw32 --with-as=/usr/bin/x86_64-w64-mingw32-as --with-ld=/usr/bin/x86_64-w64-mingw32-ld --enable-libatomic --enable-libstdcxx-filesystem-ts=yes --enable-dependency-tracking SED=/bin/sed Thread model: win32 Supported LTO compression algorithms: zlib gcc version 12-win32 (GCC) $ $ cat test-code-seg.c __declspec(code_seg("segname")) int test(void) { return 0; } $ $ x86_64-w64-mingw32-gcc -c test-code-seg.c -o test-code-seg.o test-code-seg.c:2:1: warning: 'code_seg' attribute directive ignored [-Wattributes] 2 | int test(void) { return 0; } | ^~~ $ $ x86_64-w64-mingw32-objdump -h test-code-seg.o | grep segname $