Modernize SHT_RELR support.
Until now we've only supported RELR with our own OS-private-use
constants. Add support for the official numbers (while maintaining
support for the historical numbers).
Add tests to ensure we continue to support both indefinitely.
We can't yet flip the build system over to using the official constants
because the old GNU binutils objcopy we still use in most cases (for the
mini-debug section) only supports the historical constants.
Bug: http://b/147452927
Test: treehugger
Change-Id: If214fce7fade4316115947e90b78ab40864b61f2
diff --git a/tests/libs/Android.bp b/tests/libs/Android.bp
index 2ee6c86..29224f5 100644
--- a/tests/libs/Android.bp
+++ b/tests/libs/Android.bp
@@ -1497,3 +1497,29 @@
defaults: ["bionic_testlib_defaults"],
srcs: ["segment_gap_inner.cpp"],
}
+
+
+// -----------------------------------------------------------------------------
+// Check that we support both the old and new SHT_RELR constants.
+// -----------------------------------------------------------------------------
+
+cc_test_library {
+ name: "librelr-new",
+ ldflags: ["-Wl,--no-use-android-relr-tags"],
+ host_supported: false,
+ defaults: ["bionic_testlib_defaults"],
+ srcs: ["relr.cpp"],
+ // Hack to ensure we're using llvm-objcopy because our binutils prebuilt
+ // only supports the old numbers (http://b/141010852).
+ strip: {
+ keep_symbols: true,
+ },
+}
+
+cc_test_library {
+ name: "librelr-old",
+ ldflags: ["-Wl,--use-android-relr-tags"],
+ host_supported: false,
+ defaults: ["bionic_testlib_defaults"],
+ srcs: ["relr.cpp"],
+}
diff --git a/tests/libs/relr.cpp b/tests/libs/relr.cpp
new file mode 100644
index 0000000..7ea07b5
--- /dev/null
+++ b/tests/libs/relr.cpp
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+extern "C" const char* relr() {
+ return "relr";
+}