diff --git a/test/Hexagon/linux/MoveCommonsToBSS/movecommon-to-bss.test b/test/Hexagon/linux/MoveCommonsToBSS/movecommon-to-bss.test deleted file mode 100644 index 40879d621..000000000 --- a/test/Hexagon/linux/MoveCommonsToBSS/movecommon-to-bss.test +++ /dev/null @@ -1,10 +0,0 @@ -#FIXME: How does this test checks that commons are moved to bss? -# Test that commons are moved to bss, and commons appear at the end. -RUN: %clang %clangg0opts -fcommon -c %p/Inputs/1.c -o %t1.o -RUN: %clang %clangg0opts -fcommon -c %p/Inputs/2.c -o %t2.o -RUN: %link %linkg0opts %t1.o %t2.o -o %t.out 2>&1 -RUN: %readelf -s %t.out | %filecheck %s - -#CHECK: {{[0-9]+}}: {{[x0-9a-z]+}} 4 OBJECT GLOBAL DEFAULT 1 bss -#CHECK: {{[0-9]+}}: {{[x0-9a-z]+}} 4000 OBJECT GLOBAL DEFAULT 1 common1 - diff --git a/test/Hexagon/linux/MoveCommonsToBSS/Inputs/1.c b/test/Hexagon/standalone/MoveCommonsToBSS/Inputs/1.c similarity index 100% rename from test/Hexagon/linux/MoveCommonsToBSS/Inputs/1.c rename to test/Hexagon/standalone/MoveCommonsToBSS/Inputs/1.c diff --git a/test/Hexagon/linux/MoveCommonsToBSS/Inputs/2.c b/test/Hexagon/standalone/MoveCommonsToBSS/Inputs/2.c similarity index 100% rename from test/Hexagon/linux/MoveCommonsToBSS/Inputs/2.c rename to test/Hexagon/standalone/MoveCommonsToBSS/Inputs/2.c diff --git a/test/Hexagon/standalone/MoveCommonsToBSS/movecommon-to-bss.test b/test/Hexagon/standalone/MoveCommonsToBSS/movecommon-to-bss.test new file mode 100644 index 000000000..d1f4c5ec8 --- /dev/null +++ b/test/Hexagon/standalone/MoveCommonsToBSS/movecommon-to-bss.test @@ -0,0 +1,28 @@ +## Test how common symbols and regular BSS symbols land in the output on +## Hexagon with and without -G0. Under -G0, commons +## are merged into .bss alongside regular BSS symbols. Without -G0, the +## compiler places a 4-byte bss = 0 into .sbss.4 which +## the linker folds into .sdata. common1 still ends up in .bss. + +## Single .bss holding both common1 and bss. +RUN: %clang %clangg0opts -fcommon -c %p/Inputs/1.c -o %t1.g0.o +RUN: %clang %clangg0opts -fcommon -c %p/Inputs/2.c -o %t2.g0.o +RUN: %link %linkg0opts %t1.g0.o %t2.g0.o -o %t.g0.out +RUN: %readelf -S %t.g0.out | %filecheck --check-prefix=G0-SEC %s +RUN: %readelf -s %t.g0.out | %filecheck --check-prefix=G0-SYM %s + +G0-SEC: [ 1] .bss +G0-SYM-DAG: {{[0-9]+}}: {{[x0-9a-z]+}} 4000 OBJECT GLOBAL DEFAULT 1 common1 +G0-SYM-DAG: {{[0-9]+}}: {{[x0-9a-z]+}} 4 OBJECT GLOBAL DEFAULT 1 bss + +## Non-G0 branch: `bss` in .sdata and common1 in .bss. +RUN: %clang %clangopts -fcommon -c %p/Inputs/1.c -o %t1.o +RUN: %clang %clangopts -fcommon -c %p/Inputs/2.c -o %t2.o +RUN: %link %linkopts %t1.o %t2.o -o %t.out +RUN: %readelf -S %t.out | %filecheck --check-prefix=NOG0-SEC %s +RUN: %readelf -s %t.out | %filecheck --check-prefix=NOG0-SYM %s + +NOG0-SEC: [ 1] .sdata +NOG0-SEC: [ 2] .bss +NOG0-SYM-DAG: {{[0-9]+}}: {{[x0-9a-z]+}} 4000 OBJECT GLOBAL DEFAULT 2 common1 +NOG0-SYM-DAG: {{[0-9]+}}: {{[x0-9a-z]+}} 4 OBJECT GLOBAL DEFAULT 1 bss