Specify sections to merge in segment_gap_outer.lds more precisely
https://reviews.llvm.org/D75225 changed the way that orphan sections are
retained, breaking this test. The test relied on these sections being
merged in an implementation-defined order that no longer holds true. We
can use custom sections to place the symbols we want more precisely.
Bug: http://b/161943302
Test: adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests --gtest_filter=dlfcn.segment_gap --no_isolate
Change-Id: I65656080e39be16833191cb92d3d4c41e409b216
diff --git a/tests/libs/segment_gap_outer.cpp b/tests/libs/segment_gap_outer.cpp
index 18aa3ee..3ba90d0 100644
--- a/tests/libs/segment_gap_outer.cpp
+++ b/tests/libs/segment_gap_outer.cpp
@@ -2,8 +2,8 @@
#include <dlfcn.h>
#include <stdlib.h>
-extern "C" void text_before_start_of_gap() {}
-char end_of_gap[0x1000];
+extern "C" void __attribute__((section(".custom_text"))) text_before_start_of_gap() {}
+char __attribute__((section(".custom_bss"))) end_of_gap[0x1000];
extern "C" void* get_inner() {
android_dlextinfo info = {};
diff --git a/tests/libs/segment_gap_outer.lds b/tests/libs/segment_gap_outer.lds
index 0f175af..527f29e 100644
--- a/tests/libs/segment_gap_outer.lds
+++ b/tests/libs/segment_gap_outer.lds
@@ -2,25 +2,25 @@
# This starts off fairly normal: rodata, text, dynamic, data, bss with
# appropriate alignment between them.
. = SIZEOF_HEADERS;
- .rodata : {}
+ .rodata : {*(.rodata .rodata.*)}
. = ALIGN(0x1000);
- .text : {}
+ .text : {*(.text .text.*)}
. = ALIGN(0x1000);
- .dynamic : {}
+ .dynamic : {*(.dynamic)}
. = ALIGN(0x1000);
- .data : {}
- .bss : {}
+ .data : {*(.data .data.*)}
+ .bss : {*(.bss .bss.*)}
# Now create the gap. We need a text segment first to prevent the linker from
- # merging .bss with .bss.end_of_gap.
+ # merging .bss with .custom_bss.
. = ALIGN(0x1000);
- .text.text_before_start_of_gap : {
- *(.text.text_before_start_of_gap);
+ .custom_text : {
+ *(.custom_text);
}
- # Place end_of_gap at the end of the gap.
+ # Place custom_bss at the end of the gap.
. = 0x1000000;
- .bss.end_of_gap : {
- *(.bss.*end_of_gap*);
+ .custom_bss : {
+ *(.custom_bss);
}
}