diff options
author | Dmitriy Ivanov | 2014-10-15 16:59:01 -0500 |
---|---|---|
committer | Dmitriy Ivanov | 2014-10-15 17:57:14 -0500 |
commit | ea6eae182ad64312f80b9adddac511d8938e23e7 (patch) | |
tree | c28a231f76644ba1fbbc5e467fe4d798279e10cb /linker | |
parent | 71cbcdcf947835076241b9dd72099f28997eb290 (diff) | |
download | platform-bionic-ea6eae182ad64312f80b9adddac511d8938e23e7.tar.gz platform-bionic-ea6eae182ad64312f80b9adddac511d8938e23e7.tar.xz platform-bionic-ea6eae182ad64312f80b9adddac511d8938e23e7.zip |
Ignore DT_BIND_NOW (0x18)
Bug: 17552334
Change-Id: Ibe93fd3d6580f369f9a6ef8d235bf0df00fe7607
Diffstat (limited to 'linker')
-rw-r--r-- | linker/linker.cpp | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp index fc461721..cd691afc 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp | |||
@@ -1915,27 +1915,33 @@ bool soinfo::PrelinkImage() { | |||
1915 | // TODO: glibc dynamic linker uses this name for | 1915 | // TODO: glibc dynamic linker uses this name for |
1916 | // initial library lookup; consider doing the same here. | 1916 | // initial library lookup; consider doing the same here. |
1917 | break; | 1917 | break; |
1918 | |||
1918 | case DT_HASH: | 1919 | case DT_HASH: |
1919 | nbucket = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr)[0]; | 1920 | nbucket = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr)[0]; |
1920 | nchain = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr)[1]; | 1921 | nchain = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr)[1]; |
1921 | bucket = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr + 8); | 1922 | bucket = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr + 8); |
1922 | chain = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr + 8 + nbucket * 4); | 1923 | chain = reinterpret_cast<uint32_t*>(load_bias + d->d_un.d_ptr + 8 + nbucket * 4); |
1923 | break; | 1924 | break; |
1925 | |||
1924 | case DT_STRTAB: | 1926 | case DT_STRTAB: |
1925 | strtab = reinterpret_cast<const char*>(load_bias + d->d_un.d_ptr); | 1927 | strtab = reinterpret_cast<const char*>(load_bias + d->d_un.d_ptr); |
1926 | break; | 1928 | break; |
1929 | |||
1927 | case DT_STRSZ: | 1930 | case DT_STRSZ: |
1928 | strtab_size = d->d_un.d_val; | 1931 | strtab_size = d->d_un.d_val; |
1929 | break; | 1932 | break; |
1933 | |||
1930 | case DT_SYMTAB: | 1934 | case DT_SYMTAB: |
1931 | symtab = reinterpret_cast<ElfW(Sym)*>(load_bias + d->d_un.d_ptr); | 1935 | symtab = reinterpret_cast<ElfW(Sym)*>(load_bias + d->d_un.d_ptr); |
1932 | break; | 1936 | break; |
1937 | |||
1933 | case DT_SYMENT: | 1938 | case DT_SYMENT: |
1934 | if (d->d_un.d_val != sizeof(ElfW(Sym))) { | 1939 | if (d->d_un.d_val != sizeof(ElfW(Sym))) { |
1935 | DL_ERR("invalid DT_SYMENT: %zd", static_cast<size_t>(d->d_un.d_val)); | 1940 | DL_ERR("invalid DT_SYMENT: %zd", static_cast<size_t>(d->d_un.d_val)); |
1936 | return false; | 1941 | return false; |
1937 | } | 1942 | } |
1938 | break; | 1943 | break; |
1944 | |||
1939 | case DT_PLTREL: | 1945 | case DT_PLTREL: |
1940 | #if defined(USE_RELA) | 1946 | #if defined(USE_RELA) |
1941 | if (d->d_un.d_val != DT_RELA) { | 1947 | if (d->d_un.d_val != DT_RELA) { |
@@ -1949,6 +1955,7 @@ bool soinfo::PrelinkImage() { | |||
1949 | } | 1955 | } |
1950 | #endif | 1956 | #endif |
1951 | break; | 1957 | break; |
1958 | |||
1952 | case DT_JMPREL: | 1959 | case DT_JMPREL: |
1953 | #if defined(USE_RELA) | 1960 | #if defined(USE_RELA) |
1954 | plt_rela = reinterpret_cast<ElfW(Rela)*>(load_bias + d->d_un.d_ptr); | 1961 | plt_rela = reinterpret_cast<ElfW(Rela)*>(load_bias + d->d_un.d_ptr); |
@@ -1956,6 +1963,7 @@ bool soinfo::PrelinkImage() { | |||
1956 | plt_rel = reinterpret_cast<ElfW(Rel)*>(load_bias + d->d_un.d_ptr); | 1963 | plt_rel = reinterpret_cast<ElfW(Rel)*>(load_bias + d->d_un.d_ptr); |
1957 | #endif | 1964 | #endif |
1958 | break; | 1965 | break; |
1966 | |||
1959 | case DT_PLTRELSZ: | 1967 | case DT_PLTRELSZ: |
1960 | #if defined(USE_RELA) | 1968 | #if defined(USE_RELA) |
1961 | plt_rela_count = d->d_un.d_val / sizeof(ElfW(Rela)); | 1969 | plt_rela_count = d->d_un.d_val / sizeof(ElfW(Rela)); |
@@ -1963,6 +1971,7 @@ bool soinfo::PrelinkImage() { | |||
1963 | plt_rel_count = d->d_un.d_val / sizeof(ElfW(Rel)); | 1971 | plt_rel_count = d->d_un.d_val / sizeof(ElfW(Rel)); |
1964 | #endif | 1972 | #endif |
1965 | break; | 1973 | break; |
1974 | |||
1966 | case DT_PLTGOT: | 1975 | case DT_PLTGOT: |
1967 | #if defined(__mips__) | 1976 | #if defined(__mips__) |
1968 | // Used by mips and mips64. | 1977 | // Used by mips and mips64. |
@@ -1970,6 +1979,7 @@ bool soinfo::PrelinkImage() { | |||
1970 | #endif | 1979 | #endif |
1971 | // Ignore for other platforms... (because RTLD_LAZY is not supported) | 1980 | // Ignore for other platforms... (because RTLD_LAZY is not supported) |
1972 | break; | 1981 | break; |
1982 | |||
1973 | case DT_DEBUG: | 1983 | case DT_DEBUG: |
1974 | // Set the DT_DEBUG entry to the address of _r_debug for GDB | 1984 | // Set the DT_DEBUG entry to the address of _r_debug for GDB |
1975 | // if the dynamic table is writable | 1985 | // if the dynamic table is writable |
@@ -1987,21 +1997,26 @@ bool soinfo::PrelinkImage() { | |||
1987 | case DT_RELA: | 1997 | case DT_RELA: |
1988 | rela = reinterpret_cast<ElfW(Rela)*>(load_bias + d->d_un.d_ptr); | 1998 | rela = reinterpret_cast<ElfW(Rela)*>(load_bias + d->d_un.d_ptr); |
1989 | break; | 1999 | break; |
2000 | |||
1990 | case DT_RELASZ: | 2001 | case DT_RELASZ: |
1991 | rela_count = d->d_un.d_val / sizeof(ElfW(Rela)); | 2002 | rela_count = d->d_un.d_val / sizeof(ElfW(Rela)); |
1992 | break; | 2003 | break; |
2004 | |||
1993 | case DT_RELAENT: | 2005 | case DT_RELAENT: |
1994 | if (d->d_un.d_val != sizeof(ElfW(Rela))) { | 2006 | if (d->d_un.d_val != sizeof(ElfW(Rela))) { |
1995 | DL_ERR("invalid DT_RELAENT: %zd", static_cast<size_t>(d->d_un.d_val)); | 2007 | DL_ERR("invalid DT_RELAENT: %zd", static_cast<size_t>(d->d_un.d_val)); |
1996 | return false; | 2008 | return false; |
1997 | } | 2009 | } |
1998 | break; | 2010 | break; |
2011 | |||
2012 | // ignored (see DT_RELCOUNT comments for details) | ||
1999 | case DT_RELACOUNT: | 2013 | case DT_RELACOUNT: |
2000 | // ignored (see DT_RELCOUNT comments for details) | ||
2001 | break; | 2014 | break; |
2015 | |||
2002 | case DT_REL: | 2016 | case DT_REL: |
2003 | DL_ERR("unsupported DT_REL in \"%s\"", name); | 2017 | DL_ERR("unsupported DT_REL in \"%s\"", name); |
2004 | return false; | 2018 | return false; |
2019 | |||
2005 | case DT_RELSZ: | 2020 | case DT_RELSZ: |
2006 | DL_ERR("unsupported DT_RELSZ in \"%s\"", name); | 2021 | DL_ERR("unsupported DT_RELSZ in \"%s\"", name); |
2007 | return false; | 2022 | return false; |
@@ -2009,21 +2024,24 @@ bool soinfo::PrelinkImage() { | |||
2009 | case DT_REL: | 2024 | case DT_REL: |
2010 | rel = reinterpret_cast<ElfW(Rel)*>(load_bias + d->d_un.d_ptr); | 2025 | rel = reinterpret_cast<ElfW(Rel)*>(load_bias + d->d_un.d_ptr); |
2011 | break; | 2026 | break; |
2027 | |||
2012 | case DT_RELSZ: | 2028 | case DT_RELSZ: |
2013 | rel_count = d->d_un.d_val / sizeof(ElfW(Rel)); | 2029 | rel_count = d->d_un.d_val / sizeof(ElfW(Rel)); |
2014 | break; | 2030 | break; |
2031 | |||
2015 | case DT_RELENT: | 2032 | case DT_RELENT: |
2016 | if (d->d_un.d_val != sizeof(ElfW(Rel))) { | 2033 | if (d->d_un.d_val != sizeof(ElfW(Rel))) { |
2017 | DL_ERR("invalid DT_RELENT: %zd", static_cast<size_t>(d->d_un.d_val)); | 2034 | DL_ERR("invalid DT_RELENT: %zd", static_cast<size_t>(d->d_un.d_val)); |
2018 | return false; | 2035 | return false; |
2019 | } | 2036 | } |
2020 | break; | 2037 | break; |
2038 | |||
2039 | // "Indicates that all RELATIVE relocations have been concatenated together, | ||
2040 | // and specifies the RELATIVE relocation count." | ||
2041 | // | ||
2042 | // TODO: Spec also mentions that this can be used to optimize relocation process; | ||
2043 | // Not currently used by bionic linker - ignored. | ||
2021 | case DT_RELCOUNT: | 2044 | case DT_RELCOUNT: |
2022 | // "Indicates that all RELATIVE relocations have been concatenated together, | ||
2023 | // and specifies the RELATIVE relocation count." | ||
2024 | // | ||
2025 | // TODO: Spec also mentions that this can be used to optimize relocation process; | ||
2026 | // Not currently used by bionic linker - ignored. | ||
2027 | break; | 2045 | break; |
2028 | case DT_RELA: | 2046 | case DT_RELA: |
2029 | DL_ERR("unsupported DT_RELA in \"%s\"", name); | 2047 | DL_ERR("unsupported DT_RELA in \"%s\"", name); |
@@ -2033,31 +2051,39 @@ bool soinfo::PrelinkImage() { | |||
2033 | init_func = reinterpret_cast<linker_function_t>(load_bias + d->d_un.d_ptr); | 2051 | init_func = reinterpret_cast<linker_function_t>(load_bias + d->d_un.d_ptr); |
2034 | DEBUG("%s constructors (DT_INIT) found at %p", name, init_func); | 2052 | DEBUG("%s constructors (DT_INIT) found at %p", name, init_func); |
2035 | break; | 2053 | break; |
2054 | |||
2036 | case DT_FINI: | 2055 | case DT_FINI: |
2037 | fini_func = reinterpret_cast<linker_function_t>(load_bias + d->d_un.d_ptr); | 2056 | fini_func = reinterpret_cast<linker_function_t>(load_bias + d->d_un.d_ptr); |
2038 | DEBUG("%s destructors (DT_FINI) found at %p", name, fini_func); | 2057 | DEBUG("%s destructors (DT_FINI) found at %p", name, fini_func); |
2039 | break; | 2058 | break; |
2059 | |||
2040 | case DT_INIT_ARRAY: | 2060 | case DT_INIT_ARRAY: |
2041 | init_array = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr); | 2061 | init_array = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr); |
2042 | DEBUG("%s constructors (DT_INIT_ARRAY) found at %p", name, init_array); | 2062 | DEBUG("%s constructors (DT_INIT_ARRAY) found at %p", name, init_array); |
2043 | break; | 2063 | break; |
2064 | |||
2044 | case DT_INIT_ARRAYSZ: | 2065 | case DT_INIT_ARRAYSZ: |
2045 | init_array_count = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr)); | 2066 | init_array_count = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr)); |
2046 | break; | 2067 | break; |
2068 | |||
2047 | case DT_FINI_ARRAY: | 2069 | case DT_FINI_ARRAY: |
2048 | fini_array = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr); | 2070 | fini_array = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr); |
2049 | DEBUG("%s destructors (DT_FINI_ARRAY) found at %p", name, fini_array); | 2071 | DEBUG("%s destructors (DT_FINI_ARRAY) found at %p", name, fini_array); |
2050 | break; | 2072 | break; |
2073 | |||
2051 | case DT_FINI_ARRAYSZ: | 2074 | case DT_FINI_ARRAYSZ: |
2052 | fini_array_count = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr)); | 2075 | fini_array_count = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr)); |
2053 | break; | 2076 | break; |
2077 | |||
2054 | case DT_PREINIT_ARRAY: | 2078 | case DT_PREINIT_ARRAY: |
2055 | preinit_array = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr); | 2079 | preinit_array = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr); |
2056 | DEBUG("%s constructors (DT_PREINIT_ARRAY) found at %p", name, preinit_array); | 2080 | DEBUG("%s constructors (DT_PREINIT_ARRAY) found at %p", name, preinit_array); |
2057 | break; | 2081 | break; |
2082 | |||
2058 | case DT_PREINIT_ARRAYSZ: | 2083 | case DT_PREINIT_ARRAYSZ: |
2059 | preinit_array_count = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr)); | 2084 | preinit_array_count = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr)); |
2060 | break; | 2085 | break; |
2086 | |||
2061 | case DT_TEXTREL: | 2087 | case DT_TEXTREL: |
2062 | #if defined(__LP64__) | 2088 | #if defined(__LP64__) |
2063 | DL_ERR("text relocations (DT_TEXTREL) found in 64-bit ELF file \"%s\"", name); | 2089 | DL_ERR("text relocations (DT_TEXTREL) found in 64-bit ELF file \"%s\"", name); |
@@ -2066,12 +2092,15 @@ bool soinfo::PrelinkImage() { | |||
2066 | has_text_relocations = true; | 2092 | has_text_relocations = true; |
2067 | break; | 2093 | break; |
2068 | #endif | 2094 | #endif |
2095 | |||
2069 | case DT_SYMBOLIC: | 2096 | case DT_SYMBOLIC: |
2070 | has_DT_SYMBOLIC = true; | 2097 | has_DT_SYMBOLIC = true; |
2071 | break; | 2098 | break; |
2099 | |||
2072 | case DT_NEEDED: | 2100 | case DT_NEEDED: |
2073 | ++needed_count; | 2101 | ++needed_count; |
2074 | break; | 2102 | break; |
2103 | |||
2075 | case DT_FLAGS: | 2104 | case DT_FLAGS: |
2076 | if (d->d_un.d_val & DF_TEXTREL) { | 2105 | if (d->d_un.d_val & DF_TEXTREL) { |
2077 | #if defined(__LP64__) | 2106 | #if defined(__LP64__) |
@@ -2085,6 +2114,7 @@ bool soinfo::PrelinkImage() { | |||
2085 | has_DT_SYMBOLIC = true; | 2114 | has_DT_SYMBOLIC = true; |
2086 | } | 2115 | } |
2087 | break; | 2116 | break; |
2117 | |||
2088 | case DT_FLAGS_1: | 2118 | case DT_FLAGS_1: |
2089 | if ((d->d_un.d_val & DF_1_GLOBAL) != 0) { | 2119 | if ((d->d_un.d_val & DF_1_GLOBAL) != 0) { |
2090 | rtld_flags |= RTLD_GLOBAL; | 2120 | rtld_flags |= RTLD_GLOBAL; |
@@ -2107,6 +2137,7 @@ bool soinfo::PrelinkImage() { | |||
2107 | *dp = &_r_debug; | 2137 | *dp = &_r_debug; |
2108 | } | 2138 | } |
2109 | break; | 2139 | break; |
2140 | |||
2110 | case DT_MIPS_RLD_VERSION: | 2141 | case DT_MIPS_RLD_VERSION: |
2111 | case DT_MIPS_FLAGS: | 2142 | case DT_MIPS_FLAGS: |
2112 | case DT_MIPS_BASE_ADDRESS: | 2143 | case DT_MIPS_BASE_ADDRESS: |
@@ -2125,10 +2156,14 @@ bool soinfo::PrelinkImage() { | |||
2125 | mips_gotsym = d->d_un.d_val; | 2156 | mips_gotsym = d->d_un.d_val; |
2126 | break; | 2157 | break; |
2127 | #endif | 2158 | #endif |
2159 | // Ignored: "Its use has been superseded by the DF_BIND_NOW flag" | ||
2160 | case DT_BIND_NOW: | ||
2161 | break; | ||
2162 | |||
2163 | // Ignore: bionic does not support symbol versioning... | ||
2128 | case DT_VERSYM: | 2164 | case DT_VERSYM: |
2129 | case DT_VERDEF: | 2165 | case DT_VERDEF: |
2130 | case DT_VERDEFNUM: | 2166 | case DT_VERDEFNUM: |
2131 | // Ignore: bionic does not support symbol versioning... | ||
2132 | break; | 2167 | break; |
2133 | 2168 | ||
2134 | default: | 2169 | default: |