https://sourceware.org/bugzilla/show_bug.cgi?id=29592
--- Comment #6 from matoro <matoro_bugzilla_glibc at matoro dot tk> --- *It's the other way around - CGO_ENABLED=1 is the default, creates a dynamic binary, and that is the scenario where it is not working. It works with CGO_ENABLED=0, which creates a static binary, but that is a non-default workaround. I captured this by stopping the golang link command, and taking a snapshot of its temporary link directory while frozen. What confused me was that the object code was *exactly the same* in both the good and bad directories! Then I compared the scripts with the linker invocations that I got out of pgrep and saw that they were different. The linker is getting invoked differently depending on whether the execstack warning is enabled or not. Without --enable-warn-execstack: /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../../../mips64-unknown-linux-gnu/bin/ld -plugin /usr/libexec/gcc/mips64-unknown-linux-gnu/12.2.0/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/mips64-unknown-linux-gnu/12.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccYpZeDT.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -EB -export-dynamic -dynamic-linker /lib64/ld.so.1 -melf64btsmip -o go-sqlite3.test -s /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../../../lib64/crt1.o /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../../../lib64/crti.o /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/crtbegin.o -L/usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0 -L/usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../../../lib64 -L/lib64/../lib64 -L/usr/lib64/../lib64 -L/usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../../../mips64-unknown-linux-gnu/lib -L/usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../.. -L/lib64 -L/usr/lib64 --compress-debug-sections=zlib /tmp/go-link-good/go.o /tmp/go-link-good/000000.o /tmp/go-link-good/000001.o /tmp/go-link-good/000002.o /tmp/go-link-good/000003.o /tmp/go-link-good/000004.o /tmp/go-link-good/000005.o /tmp/go-link-good/000006.o /tmp/go-link-good/000007.o /tmp/go-link-good/000008.o /tmp/go-link-good/000009.o /tmp/go-link-good/000010.o /tmp/go-link-good/000011.o /tmp/go-link-good/000012.o /tmp/go-link-good/000013.o /tmp/go-link-good/000014.o /tmp/go-link-good/000015.o /tmp/go-link-good/000016.o /tmp/go-link-good/000017.o /tmp/go-link-good/000018.o /tmp/go-link-good/000019.o /tmp/go-link-good/000020.o /tmp/go-link-good/000021.o /tmp/go-link-good/000022.o -ldl -lpthread -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/crtend.o /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../../../lib64/crtn.o With --enable-warn-execstack: /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../../../mips64-unknown-linux-gnu/bin/ld -plugin /usr/libexec/gcc/mips64-unknown-linux-gnu/12.2.0/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/mips64-unknown-linux-gnu/12.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccexkDVx.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -EB -export-dynamic -dynamic-linker /lib64/ld.so.1 -melf64btsmip -pie -o go-sqlite3.test -s /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../../../lib64/Scrt1.o /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../../../lib64/crti.o /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/crtbeginS.o -L/usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0 -L/usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../../../lib64 -L/lib64/../lib64 -L/usr/lib64/../lib64 -L/usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../../../mips64-unknown-linux-gnu/lib -L/usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../.. -L/lib64 -L/usr/lib64 /tmp/go-link-bad/go.o /tmp/go-link-bad/000000.o /tmp/go-link-bad/000001.o /tmp/go-link-bad/000002.o /tmp/go-link-bad/000003.o /tmp/go-link-bad/000004.o /tmp/go-link-bad/000005.o /tmp/go-link-bad/000006.o /tmp/go-link-bad/000007.o /tmp/go-link-bad/000008.o /tmp/go-link-bad/000009.o /tmp/go-link-bad/000010.o /tmp/go-link-bad/000011.o /tmp/go-link-bad/000012.o /tmp/go-link-bad/000013.o /tmp/go-link-bad/000014.o /tmp/go-link-bad/000015.o /tmp/go-link-bad/000016.o /tmp/go-link-bad/000017.o /tmp/go-link-bad/000018.o /tmp/go-link-bad/000019.o /tmp/go-link-bad/000020.o /tmp/go-link-bad/000021.o /tmp/go-link-bad/000022.o -ldl -lpthread -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/crtendS.o /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../../../lib64/crtn.o Diff: 7c7 < -plugin-opt=-fresolution=/tmp/ccYpZeDT.res --- > -plugin-opt=-fresolution=/tmp/ccexkDVx.res 18a19 > -pie 22c23 < /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../../../lib64/crt1.o --- > /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/../../../../lib64/Scrt1.o 24c25 < /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/crtbegin.o --- > /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/crtbeginS.o 33,57c34,57 < --compress-debug-sections=zlib < /tmp/go-link-good/go.o < /tmp/go-link-good/000000.o < /tmp/go-link-good/000001.o < /tmp/go-link-good/000002.o < /tmp/go-link-good/000003.o < /tmp/go-link-good/000004.o < /tmp/go-link-good/000005.o < /tmp/go-link-good/000006.o < /tmp/go-link-good/000007.o < /tmp/go-link-good/000008.o < /tmp/go-link-good/000009.o < /tmp/go-link-good/000010.o < /tmp/go-link-good/000011.o < /tmp/go-link-good/000012.o < /tmp/go-link-good/000013.o < /tmp/go-link-good/000014.o < /tmp/go-link-good/000015.o < /tmp/go-link-good/000016.o < /tmp/go-link-good/000017.o < /tmp/go-link-good/000018.o < /tmp/go-link-good/000019.o < /tmp/go-link-good/000020.o < /tmp/go-link-good/000021.o < /tmp/go-link-good/000022.o --- > /tmp/go-link-bad/go.o > /tmp/go-link-bad/000000.o > /tmp/go-link-bad/000001.o > /tmp/go-link-bad/000002.o > /tmp/go-link-bad/000003.o > /tmp/go-link-bad/000004.o > /tmp/go-link-bad/000005.o > /tmp/go-link-bad/000006.o > /tmp/go-link-bad/000007.o > /tmp/go-link-bad/000008.o > /tmp/go-link-bad/000009.o > /tmp/go-link-bad/000010.o > /tmp/go-link-bad/000011.o > /tmp/go-link-bad/000012.o > /tmp/go-link-bad/000013.o > /tmp/go-link-bad/000014.o > /tmp/go-link-bad/000015.o > /tmp/go-link-bad/000016.o > /tmp/go-link-bad/000017.o > /tmp/go-link-bad/000018.o > /tmp/go-link-bad/000019.o > /tmp/go-link-bad/000020.o > /tmp/go-link-bad/000021.o > /tmp/go-link-bad/000022.o 71c71 < /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/crtend.o --- > /usr/lib/gcc/mips64-unknown-linux-gnu/12.2.0/crtendS.o You can see that after the change, it seems to be enabling PIE in the bad scenario, when it presumably should not. -- You are receiving this mail because: You are on the CC list for the bug.