Stop defining our own PAGE_SIZE and PAGE_MASK, and test dlclose(3) too.
Also remove an unnecessary #include and a now-obsolete TODO.
Change-Id: I36d923721e349a286934b9534090a67ce0786e7b
diff --git a/linker/linker.cpp b/linker/linker.cpp
index f7f8125..5c43cd0 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -72,8 +72,6 @@
* - cleaner error reporting
* - after linking, set as much stuff as possible to READONLY
* and NOEXEC
- * - linker hardcodes PAGE_SIZE and PAGE_MASK because the kernel
- * headers provide versions that are negative...
*/
diff --git a/linker/linker.h b/linker/linker.h
index de83a8c..2a6c1cd 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -36,25 +36,14 @@
#include <link.h>
-#undef PAGE_MASK
-#undef PAGE_SIZE
-#define PAGE_SIZE 4096
-#define PAGE_MASK (PAGE_SIZE-1)
+// Returns the address of the page containing address 'x'.
+#define PAGE_START(x) ((x) & PAGE_MASK)
-/* Convenience macros to make page address/offset computations more explicit */
+// Returns the offset of address 'x' in its page.
+#define PAGE_OFFSET(x) ((x) & ~PAGE_MASK)
-/* Returns the address of the page starting at address 'x' */
-#define PAGE_START(x) ((x) & ~PAGE_MASK)
-
-/* Returns the offset of address 'x' in its memory page, i.e. this is the
- * same than 'x' - PAGE_START(x) */
-#define PAGE_OFFSET(x) ((x) & PAGE_MASK)
-
-/* Returns the address of the next page after address 'x', unless 'x' is
- * itself at the start of a page. Equivalent to:
- *
- * (x == PAGE_START(x)) ? x : PAGE_START(x)+PAGE_SIZE
- */
+// Returns the address of the next page after address 'x', unless 'x' is
+// itself at the start of a page.
#define PAGE_END(x) PAGE_START((x) + (PAGE_SIZE-1))
void debugger_init();
@@ -167,9 +156,6 @@
extern soinfo libdl_info;
-
-#include <asm/elf.h>
-
#if defined(ANDROID_ARM_LINKER)
// These aren't defined in <arch-arm/asm/elf.h>.
diff --git a/tests/dlopen_test.cpp b/tests/dlopen_test.cpp
index 024df01..794fb97 100644
--- a/tests/dlopen_test.cpp
+++ b/tests/dlopen_test.cpp
@@ -46,6 +46,8 @@
gCalled = false;
function();
ASSERT_TRUE(gCalled);
+
+ ASSERT_EQ(0, dlclose(self));
}
TEST(dlopen, dlopen_failure) {
@@ -108,6 +110,8 @@
sym = dlsym(self, "ThisSymbolDoesNotExist");
ASSERT_TRUE(sym == NULL);
ASSERT_SUBSTR("undefined symbol: ThisSymbolDoesNotExist", dlerror());
+
+ ASSERT_EQ(0, dlclose(self));
}
TEST(dlopen, dladdr) {
@@ -166,6 +170,8 @@
// The base address should be the address we were loaded at.
ASSERT_EQ(info.dli_fbase, base_address);
+
+ ASSERT_EQ(0, dlclose(self));
}
TEST(dlopen, dladdr_invalid) {