am 064f862d: Merge "Stop defining our own PAGE_SIZE and PAGE_MASK, and test dlclose(3) too."

* commit '064f862d557ab741575dfae479499a07ca0ab742':
  Stop defining our own PAGE_SIZE and PAGE_MASK, and test dlclose(3) too.
This commit is contained in:
Elliott Hughes 2012-11-01 14:14:00 -07:00 committed by Android Git Automerger
commit 65ba5b62c5
3 changed files with 12 additions and 22 deletions

View File

@ -72,8 +72,6 @@
* - cleaner error reporting * - cleaner error reporting
* - after linking, set as much stuff as possible to READONLY * - after linking, set as much stuff as possible to READONLY
* and NOEXEC * and NOEXEC
* - linker hardcodes PAGE_SIZE and PAGE_MASK because the kernel
* headers provide versions that are negative...
*/ */

View File

@ -36,25 +36,14 @@
#include <link.h> #include <link.h>
#undef PAGE_MASK // Returns the address of the page containing address 'x'.
#undef PAGE_SIZE #define PAGE_START(x) ((x) & PAGE_MASK)
#define PAGE_SIZE 4096
#define PAGE_MASK (PAGE_SIZE-1)
/* 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' */ // Returns the address of the next page after address 'x', unless 'x' is
#define PAGE_START(x) ((x) & ~PAGE_MASK) // itself at the start of a page.
/* 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
*/
#define PAGE_END(x) PAGE_START((x) + (PAGE_SIZE-1)) #define PAGE_END(x) PAGE_START((x) + (PAGE_SIZE-1))
void debugger_init(); void debugger_init();
@ -167,9 +156,6 @@ struct soinfo {
extern soinfo libdl_info; extern soinfo libdl_info;
#include <asm/elf.h>
#if defined(ANDROID_ARM_LINKER) #if defined(ANDROID_ARM_LINKER)
// These aren't defined in <arch-arm/asm/elf.h>. // These aren't defined in <arch-arm/asm/elf.h>.

View File

@ -46,6 +46,8 @@ TEST(dlopen, dlsym_in_self) {
gCalled = false; gCalled = false;
function(); function();
ASSERT_TRUE(gCalled); ASSERT_TRUE(gCalled);
ASSERT_EQ(0, dlclose(self));
} }
TEST(dlopen, dlopen_failure) { TEST(dlopen, dlopen_failure) {
@ -108,6 +110,8 @@ TEST(dlopen, dlsym_failures) {
sym = dlsym(self, "ThisSymbolDoesNotExist"); sym = dlsym(self, "ThisSymbolDoesNotExist");
ASSERT_TRUE(sym == NULL); ASSERT_TRUE(sym == NULL);
ASSERT_SUBSTR("undefined symbol: ThisSymbolDoesNotExist", dlerror()); ASSERT_SUBSTR("undefined symbol: ThisSymbolDoesNotExist", dlerror());
ASSERT_EQ(0, dlclose(self));
} }
TEST(dlopen, dladdr) { TEST(dlopen, dladdr) {
@ -166,6 +170,8 @@ TEST(dlopen, dladdr) {
// The base address should be the address we were loaded at. // The base address should be the address we were loaded at.
ASSERT_EQ(info.dli_fbase, base_address); ASSERT_EQ(info.dli_fbase, base_address);
ASSERT_EQ(0, dlclose(self));
} }
TEST(dlopen, dladdr_invalid) { TEST(dlopen, dladdr_invalid) {