dl-elf.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * This file contains the helper routines to load an ELF shared
  4. * library into memory and add the symbol table info to the chain.
  5. *
  6. * Copyright (C) 2000-2006 by Erik Andersen <andersen@codepoet.org>
  7. * Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
  8. * David Engel, Hongjiu Lu and Mitch D'Souza
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. The name of the above contributors may not be
  16. * used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
  23. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. * SUCH DAMAGE.
  30. */
  31. #include "ldso.h"
  32. #ifdef __LDSO_CACHE_SUPPORT__
  33. static caddr_t _dl_cache_addr = NULL;
  34. static size_t _dl_cache_size = 0;
  35. int _dl_map_cache(void)
  36. {
  37. int fd;
  38. struct stat st;
  39. header_t *header;
  40. libentry_t *libent;
  41. int i, strtabsize;
  42. if (_dl_cache_addr == MAP_FAILED)
  43. return -1;
  44. else if (_dl_cache_addr != NULL)
  45. return 0;
  46. if (_dl_stat(LDSO_CACHE, &st)
  47. || (fd = _dl_open(LDSO_CACHE, O_RDONLY|O_CLOEXEC, 0)) < 0) {
  48. _dl_cache_addr = MAP_FAILED; /* so we won't try again */
  49. return -1;
  50. }
  51. _dl_cache_size = st.st_size;
  52. _dl_cache_addr = _dl_mmap(0, _dl_cache_size, PROT_READ, LDSO_CACHE_MMAP_FLAGS, fd, 0);
  53. _dl_close(fd);
  54. if (_dl_mmap_check_error(_dl_cache_addr)) {
  55. _dl_dprintf(2, "%s:%i: can't map '%s'\n",
  56. _dl_progname, __LINE__, LDSO_CACHE);
  57. return -1;
  58. }
  59. header = (header_t *) _dl_cache_addr;
  60. if (_dl_cache_size < sizeof(header_t) ||
  61. _dl_memcmp(header->magic, LDSO_CACHE_MAGIC, LDSO_CACHE_MAGIC_LEN)
  62. || _dl_memcmp(header->version, LDSO_CACHE_VER, LDSO_CACHE_VER_LEN)
  63. || _dl_cache_size <
  64. (sizeof(header_t) + header->nlibs * sizeof(libentry_t))
  65. || _dl_cache_addr[_dl_cache_size - 1] != '\0')
  66. {
  67. _dl_dprintf(2, "%s: cache '%s' is corrupt\n", _dl_progname,
  68. LDSO_CACHE);
  69. goto fail;
  70. }
  71. strtabsize = _dl_cache_size - sizeof(header_t) -
  72. header->nlibs * sizeof(libentry_t);
  73. libent = (libentry_t *) & header[1];
  74. for (i = 0; i < header->nlibs; i++) {
  75. if (libent[i].sooffset >= strtabsize ||
  76. libent[i].liboffset >= strtabsize)
  77. {
  78. _dl_dprintf(2, "%s: cache '%s' is corrupt\n", _dl_progname, LDSO_CACHE);
  79. goto fail;
  80. }
  81. }
  82. return 0;
  83. fail:
  84. _dl_munmap(_dl_cache_addr, _dl_cache_size);
  85. _dl_cache_addr = MAP_FAILED;
  86. return -1;
  87. }
  88. int _dl_unmap_cache(void)
  89. {
  90. if (_dl_cache_addr == NULL || _dl_cache_addr == MAP_FAILED)
  91. return -1;
  92. #if 1
  93. _dl_munmap(_dl_cache_addr, _dl_cache_size);
  94. _dl_cache_addr = NULL;
  95. #endif
  96. return 0;
  97. }
  98. #endif
  99. void
  100. _dl_protect_relro (struct elf_resolve *l)
  101. {
  102. ElfW(Addr) base = (ElfW(Addr)) DL_RELOC_ADDR(l->loadaddr, l->relro_addr);
  103. ElfW(Addr) start = (base & PAGE_ALIGN);
  104. ElfW(Addr) end = ((base + l->relro_size) & PAGE_ALIGN);
  105. _dl_if_debug_dprint("RELRO protecting %s: start:%x, end:%x\n", l->libname, start, end);
  106. if (start != end &&
  107. _dl_mprotect ((void *) start, end - start, PROT_READ) < 0) {
  108. _dl_dprintf(2, "%s: cannot apply additional memory protection after relocation", l->libname);
  109. _dl_exit(0);
  110. }
  111. }
  112. /* This function's behavior must exactly match that
  113. * in uClibc/ldso/util/ldd.c */
  114. static struct elf_resolve *
  115. search_for_named_library(const char *name, unsigned rflags, const char *path_list,
  116. struct dyn_elf **rpnt)
  117. {
  118. char *path, *path_n, *mylibname;
  119. struct elf_resolve *tpnt;
  120. int done;
  121. if (path_list==NULL)
  122. return NULL;
  123. /* We need a writable copy of this string, but we don't
  124. * need this allocated permanently since we don't want
  125. * to leak memory, so use alloca to put path on the stack */
  126. done = _dl_strlen(path_list);
  127. path = alloca(done + 1);
  128. /* another bit of local storage */
  129. mylibname = alloca(2050);
  130. _dl_memcpy(path, path_list, done+1);
  131. /* Unlike ldd.c, don't bother to eliminate double //s */
  132. /* Replace colons with zeros in path_list */
  133. /* : at the beginning or end of path maps to CWD */
  134. /* :: anywhere maps CWD */
  135. /* "" maps to CWD */
  136. done = 0;
  137. path_n = path;
  138. do {
  139. if (*path == 0) {
  140. *path = ':';
  141. done = 1;
  142. }
  143. if (*path == ':') {
  144. *path = 0;
  145. if (*path_n)
  146. _dl_strcpy(mylibname, path_n);
  147. else
  148. _dl_strcpy(mylibname, "."); /* Assume current dir if empty path */
  149. _dl_strcat(mylibname, "/");
  150. _dl_strcat(mylibname, name);
  151. if ((tpnt = _dl_load_elf_shared_library(rflags, rpnt, mylibname)) != NULL)
  152. return tpnt;
  153. path_n = path+1;
  154. }
  155. path++;
  156. } while (!done);
  157. return NULL;
  158. }
  159. /* Used to return error codes back to dlopen et. al. */
  160. unsigned long _dl_error_number;
  161. unsigned long _dl_internal_error_number;
  162. struct elf_resolve *_dl_load_shared_library(unsigned rflags, struct dyn_elf **rpnt,
  163. struct elf_resolve *tpnt, char *full_libname, int attribute_unused trace_loaded_objects)
  164. {
  165. char *pnt;
  166. struct elf_resolve *tpnt1;
  167. char *libname;
  168. _dl_internal_error_number = 0;
  169. libname = full_libname;
  170. /* quick hack to ensure mylibname buffer doesn't overflow. don't
  171. allow full_libname or any directory to be longer than 1024. */
  172. if (_dl_strlen(full_libname) > 1024)
  173. goto goof;
  174. /* Skip over any initial initial './' and '/' stuff to
  175. * get the short form libname with no path garbage */
  176. pnt = _dl_strrchr(libname, '/');
  177. if (pnt) {
  178. libname = pnt + 1;
  179. }
  180. _dl_if_debug_dprint("\tfind library='%s'; searching\n", libname);
  181. /* If the filename has any '/', try it straight and leave it at that.
  182. For IBCS2 compatibility under linux, we substitute the string
  183. /usr/i486-sysv4/lib for /usr/lib in library names. */
  184. if (libname != full_libname) {
  185. _dl_if_debug_dprint("\ttrying file='%s'\n", full_libname);
  186. tpnt1 = _dl_load_elf_shared_library(rflags, rpnt, full_libname);
  187. if (tpnt1) {
  188. return tpnt1;
  189. }
  190. }
  191. /*
  192. * The ABI specifies that RPATH is searched before LD_LIBRARY_PATH or
  193. * the default path of /usr/lib. Check in rpath directories.
  194. */
  195. #ifdef __LDSO_RUNPATH__
  196. pnt = (tpnt ? (char *) tpnt->dynamic_info[DT_RPATH] : NULL);
  197. if (pnt) {
  198. pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
  199. _dl_if_debug_dprint("\tsearching RPATH='%s'\n", pnt);
  200. if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt)) != NULL)
  201. return tpnt1;
  202. }
  203. #endif
  204. #ifdef __LDSO_LD_LIBRARY_PATH__
  205. /* Check in LD_{ELF_}LIBRARY_PATH, if specified and allowed */
  206. if (_dl_library_path) {
  207. _dl_if_debug_dprint("\tsearching LD_LIBRARY_PATH='%s'\n", _dl_library_path);
  208. if ((tpnt1 = search_for_named_library(libname, rflags, _dl_library_path, rpnt)) != NULL)
  209. {
  210. return tpnt1;
  211. }
  212. }
  213. #endif
  214. /*
  215. * The ABI specifies that RUNPATH is searched after LD_LIBRARY_PATH.
  216. */
  217. #ifdef __LDSO_RUNPATH__
  218. pnt = (tpnt ? (char *)tpnt->dynamic_info[DT_RUNPATH] : NULL);
  219. if (pnt) {
  220. pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
  221. _dl_if_debug_dprint("\tsearching RUNPATH='%s'\n", pnt);
  222. if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt)) != NULL)
  223. return tpnt1;
  224. }
  225. #endif
  226. /*
  227. * Where should the cache be searched? There is no such concept in the
  228. * ABI, so we have some flexibility here. For now, search it before
  229. * the hard coded paths that follow (i.e before /lib and /usr/lib).
  230. */
  231. #ifdef __LDSO_CACHE_SUPPORT__
  232. if (_dl_cache_addr != NULL && _dl_cache_addr != MAP_FAILED) {
  233. int i;
  234. header_t *header = (header_t *) _dl_cache_addr;
  235. libentry_t *libent = (libentry_t *) & header[1];
  236. char *strs = (char *) &libent[header->nlibs];
  237. _dl_if_debug_dprint("\tsearching cache='%s'\n", LDSO_CACHE);
  238. for (i = 0; i < header->nlibs; i++) {
  239. if ((libent[i].flags == LIB_ELF
  240. || libent[i].flags == LIB_ELF_LIBC0
  241. || libent[i].flags == LIB_ELF_LIBC5)
  242. && _dl_strcmp(libname, strs + libent[i].sooffset) == 0
  243. && (tpnt1 = _dl_load_elf_shared_library(rflags, rpnt, strs + libent[i].liboffset))
  244. ) {
  245. return tpnt1;
  246. }
  247. }
  248. }
  249. #endif
  250. #if defined SHARED && defined __LDSO_SEARCH_INTERP_PATH__
  251. /* Look for libraries wherever the shared library loader
  252. * was installed */
  253. _dl_if_debug_dprint("\tsearching ldso dir='%s'\n", _dl_ldsopath);
  254. tpnt1 = search_for_named_library(libname, rflags, _dl_ldsopath, rpnt);
  255. if (tpnt1 != NULL)
  256. return tpnt1;
  257. #endif
  258. /* Lastly, search the standard list of paths for the library.
  259. This list must exactly match the list in uClibc/ldso/util/ldd.c */
  260. _dl_if_debug_dprint("\tsearching full lib path list\n");
  261. tpnt1 = search_for_named_library(libname, rflags,
  262. UCLIBC_RUNTIME_PREFIX "lib:"
  263. UCLIBC_RUNTIME_PREFIX "usr/lib"
  264. #ifndef __LDSO_CACHE_SUPPORT__
  265. ":" UCLIBC_RUNTIME_PREFIX "usr/X11R6/lib"
  266. #endif
  267. , rpnt);
  268. if (tpnt1 != NULL)
  269. return tpnt1;
  270. goof:
  271. /* Well, we shot our wad on that one. All we can do now is punt */
  272. if (_dl_internal_error_number)
  273. _dl_error_number = _dl_internal_error_number;
  274. else
  275. _dl_error_number = LD_ERROR_NOFILE;
  276. _dl_if_debug_dprint("Bummer: could not find '%s'!\n", libname);
  277. return NULL;
  278. }
  279. /*
  280. * Make a writeable mapping of a segment, regardless of whether PF_W is
  281. * set or not.
  282. */
  283. static void *
  284. map_writeable (int infile, ElfW(Phdr) *ppnt, int piclib, int flags,
  285. unsigned long libaddr)
  286. {
  287. int prot_flags = ppnt->p_flags | PF_W;
  288. char *status, *retval;
  289. char *tryaddr;
  290. ssize_t size;
  291. unsigned long map_size;
  292. char *cpnt;
  293. char *piclib2map = NULL;
  294. if (piclib == 2 &&
  295. /* We might be able to avoid this call if memsz doesn't
  296. require an additional page, but this would require mmap
  297. to always return page-aligned addresses and a whole
  298. number of pages allocated. Unfortunately on uClinux
  299. may return misaligned addresses and may allocate
  300. partial pages, so we may end up doing unnecessary mmap
  301. calls.
  302. This is what we could do if we knew mmap would always
  303. return aligned pages:
  304. ((ppnt->p_vaddr + ppnt->p_filesz + ADDR_ALIGN) &
  305. PAGE_ALIGN) < ppnt->p_vaddr + ppnt->p_memsz)
  306. Instead, we have to do this: */
  307. ppnt->p_filesz < ppnt->p_memsz)
  308. {
  309. piclib2map = (char *)
  310. _dl_mmap(0, (ppnt->p_vaddr & ADDR_ALIGN) + ppnt->p_memsz,
  311. LXFLAGS(prot_flags), flags | MAP_ANONYMOUS, -1, 0);
  312. if (_dl_mmap_check_error(piclib2map))
  313. return 0;
  314. }
  315. tryaddr = piclib == 2 ? piclib2map
  316. : ((char*) (piclib ? libaddr : 0) +
  317. (ppnt->p_vaddr & PAGE_ALIGN));
  318. size = (ppnt->p_vaddr & ADDR_ALIGN) + ppnt->p_filesz;
  319. /* For !MMU, mmap to fixed address will fail.
  320. So instead of desperately call mmap and fail,
  321. we set status to MAP_FAILED to save a call
  322. to mmap (). */
  323. #ifndef __ARCH_USE_MMU__
  324. if (piclib2map == 0)
  325. #endif
  326. status = (char *) _dl_mmap
  327. (tryaddr, size, LXFLAGS(prot_flags),
  328. flags | (piclib2map ? MAP_FIXED : 0),
  329. infile, ppnt->p_offset & OFFS_ALIGN);
  330. #ifndef __ARCH_USE_MMU__
  331. else
  332. status = MAP_FAILED;
  333. #endif
  334. #ifdef _DL_PREAD
  335. if (_dl_mmap_check_error(status) && piclib2map
  336. && (_DL_PREAD (infile, tryaddr, size,
  337. ppnt->p_offset & OFFS_ALIGN) == size))
  338. status = tryaddr;
  339. #endif
  340. if (_dl_mmap_check_error(status) || (tryaddr && tryaddr != status))
  341. return 0;
  342. if (piclib2map)
  343. retval = piclib2map;
  344. else
  345. retval = status;
  346. /* Now we want to allocate and zero-out any data from the end
  347. of the region we mapped in from the file (filesz) to the
  348. end of the loadable segment (memsz). We may need
  349. additional pages for memsz, that we map in below, and we
  350. can count on the kernel to zero them out, but we have to
  351. zero out stuff in the last page that we mapped in from the
  352. file. However, we can't assume to have actually obtained
  353. full pages from the kernel, since we didn't ask for them,
  354. and uClibc may not give us full pages for small
  355. allocations. So only zero out up to memsz or the end of
  356. the page, whichever comes first. */
  357. /* CPNT is the beginning of the memsz portion not backed by
  358. filesz. */
  359. cpnt = (char *) (status + size);
  360. /* MAP_SIZE is the address of the
  361. beginning of the next page. */
  362. map_size = (ppnt->p_vaddr + ppnt->p_filesz
  363. + ADDR_ALIGN) & PAGE_ALIGN;
  364. _dl_memset (cpnt, 0,
  365. MIN (map_size
  366. - (ppnt->p_vaddr
  367. + ppnt->p_filesz),
  368. ppnt->p_memsz
  369. - ppnt->p_filesz));
  370. if (map_size < ppnt->p_vaddr + ppnt->p_memsz && !piclib2map) {
  371. tryaddr = map_size + (char*)(piclib ? libaddr : 0);
  372. status = (char *) _dl_mmap(tryaddr,
  373. ppnt->p_vaddr + ppnt->p_memsz - map_size,
  374. LXFLAGS(prot_flags),
  375. flags | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
  376. if (_dl_mmap_check_error(status) || tryaddr != status)
  377. return NULL;
  378. }
  379. return retval;
  380. }
  381. /*
  382. * Read one ELF library into memory, mmap it into the correct locations and
  383. * add the symbol info to the symbol chain. Perform any relocations that
  384. * are required.
  385. */
  386. struct elf_resolve *_dl_load_elf_shared_library(unsigned rflags,
  387. struct dyn_elf **rpnt, const char *libname)
  388. {
  389. ElfW(Ehdr) *epnt;
  390. unsigned long dynamic_addr = 0;
  391. ElfW(Dyn) *dpnt;
  392. struct elf_resolve *tpnt;
  393. ElfW(Phdr) *ppnt;
  394. #if defined(USE_TLS) && USE_TLS
  395. ElfW(Phdr) *tlsppnt = NULL;
  396. #endif
  397. char *status, *header;
  398. unsigned long dynamic_info[DYNAMIC_SIZE];
  399. unsigned long *lpnt;
  400. unsigned long libaddr;
  401. unsigned long minvma = 0xffffffff, maxvma = 0;
  402. unsigned int rtld_flags;
  403. int i, flags, piclib, infile;
  404. ElfW(Addr) relro_addr = 0;
  405. size_t relro_size = 0;
  406. struct stat st;
  407. uint32_t *p32;
  408. DL_LOADADDR_TYPE lib_loadaddr = 0;
  409. DL_INIT_LOADADDR_EXTRA_DECLS
  410. libaddr = 0;
  411. infile = _dl_open(libname, O_RDONLY, 0);
  412. if (infile < 0) {
  413. _dl_internal_error_number = LD_ERROR_NOFILE;
  414. return NULL;
  415. }
  416. if (_dl_fstat(infile, &st) < 0) {
  417. _dl_internal_error_number = LD_ERROR_NOFILE;
  418. _dl_close(infile);
  419. return NULL;
  420. }
  421. /* If we are in secure mode (i.e. a setuid/gid binary using LD_PRELOAD),
  422. we don't load the library if it isn't setuid. */
  423. if (rflags & DL_RESOLVE_SECURE) {
  424. if (!(st.st_mode & S_ISUID)) {
  425. _dl_close(infile);
  426. return NULL;
  427. }
  428. }
  429. /* Check if file is already loaded */
  430. for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
  431. if (tpnt->st_dev == st.st_dev && tpnt->st_ino == st.st_ino) {
  432. /* Already loaded */
  433. tpnt->usage_count++;
  434. _dl_close(infile);
  435. return tpnt;
  436. }
  437. }
  438. if (rflags & DL_RESOLVE_NOLOAD) {
  439. _dl_close(infile);
  440. return NULL;
  441. }
  442. header = _dl_mmap((void *) 0, _dl_pagesize, PROT_READ | PROT_WRITE,
  443. MAP_PRIVATE | MAP_ANONYMOUS | MAP_UNINITIALIZE, -1, 0);
  444. if (_dl_mmap_check_error(header)) {
  445. _dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname);
  446. _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
  447. _dl_close(infile);
  448. return NULL;
  449. }
  450. _dl_read(infile, header, _dl_pagesize);
  451. epnt = (ElfW(Ehdr) *) (intptr_t) header;
  452. p32 = (uint32_t*)&epnt->e_ident;
  453. if (*p32 != ELFMAG_U32) {
  454. _dl_dprintf(2, "%s: '%s' is not an ELF file\n", _dl_progname,
  455. libname);
  456. _dl_internal_error_number = LD_ERROR_NOTELF;
  457. _dl_close(infile);
  458. _dl_munmap(header, _dl_pagesize);
  459. return NULL;
  460. }
  461. if ((epnt->e_type != ET_DYN
  462. #ifdef __LDSO_STANDALONE_SUPPORT__
  463. && epnt->e_type != ET_EXEC
  464. #endif
  465. ) || (epnt->e_machine != MAGIC1
  466. #ifdef MAGIC2
  467. && epnt->e_machine != MAGIC2
  468. #endif
  469. ))
  470. {
  471. _dl_internal_error_number =
  472. (epnt->e_type != ET_DYN ? LD_ERROR_NOTDYN : LD_ERROR_NOTMAGIC);
  473. _dl_dprintf(2, "%s: '%s' is not an ELF executable for " ELF_TARGET
  474. "\n", _dl_progname, libname);
  475. _dl_close(infile);
  476. _dl_munmap(header, _dl_pagesize);
  477. return NULL;
  478. }
  479. ppnt = (ElfW(Phdr) *)(intptr_t) & header[epnt->e_phoff];
  480. piclib = 1;
  481. for (i = 0; i < epnt->e_phnum; i++) {
  482. if (ppnt->p_type == PT_DYNAMIC) {
  483. if (dynamic_addr)
  484. _dl_dprintf(2, "%s: '%s' has more than one dynamic section\n",
  485. _dl_progname, libname);
  486. dynamic_addr = ppnt->p_vaddr;
  487. }
  488. if (ppnt->p_type == PT_LOAD) {
  489. /* See if this is a PIC library. */
  490. if (minvma == 0xffffffff && ppnt->p_vaddr > 0x1000000) {
  491. piclib = 0;
  492. minvma = ppnt->p_vaddr;
  493. }
  494. if (piclib && ppnt->p_vaddr < minvma) {
  495. minvma = ppnt->p_vaddr;
  496. }
  497. if (((unsigned long) ppnt->p_vaddr + ppnt->p_memsz) > maxvma) {
  498. maxvma = ppnt->p_vaddr + ppnt->p_memsz;
  499. }
  500. }
  501. if (ppnt->p_type == PT_TLS) {
  502. #if defined(USE_TLS) && USE_TLS
  503. if (ppnt->p_memsz == 0)
  504. /* Nothing to do for an empty segment. */
  505. continue;
  506. else
  507. /* Save for after 'tpnt' is actually allocated. */
  508. tlsppnt = ppnt;
  509. #else
  510. /*
  511. * Yup, the user was an idiot and tried to sneak in a library with
  512. * TLS in it and we don't support it. Let's fall on our own sword
  513. * and scream at the luser while we die.
  514. */
  515. _dl_dprintf(2, "%s: '%s' library contains unsupported TLS\n",
  516. _dl_progname, libname);
  517. _dl_internal_error_number = LD_ERROR_TLS_FAILED;
  518. _dl_close(infile);
  519. _dl_munmap(header, _dl_pagesize);
  520. return NULL;
  521. #endif
  522. }
  523. ppnt++;
  524. }
  525. #ifdef __LDSO_STANDALONE_SUPPORT__
  526. if (epnt->e_type == ET_EXEC)
  527. piclib = 0;
  528. #endif
  529. DL_CHECK_LIB_TYPE (epnt, piclib, _dl_progname, libname);
  530. maxvma = (maxvma + ADDR_ALIGN) & PAGE_ALIGN;
  531. minvma = minvma & ~ADDR_ALIGN;
  532. flags = MAP_PRIVATE /*| MAP_DENYWRITE */ ;
  533. if (piclib == 0 || piclib == 1) {
  534. status = (char *) _dl_mmap((char *) (piclib ? 0 : minvma),
  535. maxvma - minvma, PROT_NONE, flags | MAP_ANONYMOUS, -1, 0);
  536. if (_dl_mmap_check_error(status)) {
  537. cant_map:
  538. _dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname);
  539. _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
  540. _dl_close(infile);
  541. _dl_munmap(header, _dl_pagesize);
  542. return NULL;
  543. }
  544. libaddr = (unsigned long) status;
  545. flags |= MAP_FIXED;
  546. }
  547. /* Get the memory to store the library */
  548. ppnt = (ElfW(Phdr) *)(intptr_t) & header[epnt->e_phoff];
  549. DL_INIT_LOADADDR(lib_loadaddr, libaddr - minvma, ppnt, epnt->e_phnum);
  550. for (i = 0; i < epnt->e_phnum; i++) {
  551. if (DL_IS_SPECIAL_SEGMENT (epnt, ppnt)) {
  552. char *addr;
  553. addr = DL_MAP_SEGMENT (epnt, ppnt, infile, flags);
  554. if (addr == NULL) {
  555. cant_map1:
  556. DL_LOADADDR_UNMAP (lib_loadaddr, maxvma - minvma);
  557. goto cant_map;
  558. }
  559. DL_INIT_LOADADDR_HDR (lib_loadaddr, addr, ppnt);
  560. ppnt++;
  561. continue;
  562. }
  563. if (ppnt->p_type == PT_GNU_RELRO) {
  564. relro_addr = ppnt->p_vaddr;
  565. relro_size = ppnt->p_memsz;
  566. }
  567. if (ppnt->p_type == PT_LOAD) {
  568. char *tryaddr;
  569. ssize_t size;
  570. if (ppnt->p_flags & PF_W) {
  571. status = map_writeable (infile, ppnt, piclib, flags, libaddr);
  572. if (status == NULL)
  573. goto cant_map1;
  574. } else {
  575. tryaddr = (piclib == 2 ? 0
  576. : (char *) (ppnt->p_vaddr & PAGE_ALIGN)
  577. + (piclib ? libaddr : lib_loadaddr));
  578. size = (ppnt->p_vaddr & ADDR_ALIGN) + ppnt->p_filesz;
  579. status = (char *) _dl_mmap
  580. (tryaddr, size, LXFLAGS(ppnt->p_flags),
  581. flags | (piclib == 2 ? MAP_EXECUTABLE
  582. | MAP_DENYWRITE : 0),
  583. infile, ppnt->p_offset & OFFS_ALIGN);
  584. if (_dl_mmap_check_error(status)
  585. || (tryaddr && tryaddr != status))
  586. goto cant_map1;
  587. }
  588. DL_INIT_LOADADDR_HDR(lib_loadaddr,
  589. status + (ppnt->p_vaddr & ADDR_ALIGN),
  590. ppnt);
  591. /* if (libaddr == 0 && piclib) {
  592. libaddr = (unsigned long) status;
  593. flags |= MAP_FIXED;
  594. } */
  595. }
  596. ppnt++;
  597. }
  598. /*
  599. * The dynamic_addr must be take into acount lib_loadaddr value, to note
  600. * it is zero when the SO has been mapped to the elf's physical addr
  601. */
  602. if (lib_loadaddr) {
  603. dynamic_addr = (unsigned long) DL_RELOC_ADDR(lib_loadaddr, dynamic_addr);
  604. }
  605. /*
  606. * OK, the ELF library is now loaded into VM in the correct locations
  607. * The next step is to go through and do the dynamic linking (if needed).
  608. */
  609. /* Start by scanning the dynamic section to get all of the pointers */
  610. if (!dynamic_addr) {
  611. _dl_internal_error_number = LD_ERROR_NODYNAMIC;
  612. _dl_dprintf(2, "%s: '%s' is missing a dynamic section\n",
  613. _dl_progname, libname);
  614. _dl_munmap(header, _dl_pagesize);
  615. _dl_close(infile);
  616. return NULL;
  617. }
  618. dpnt = (ElfW(Dyn) *) dynamic_addr;
  619. _dl_memset(dynamic_info, 0, sizeof(dynamic_info));
  620. rtld_flags = _dl_parse_dynamic_info(dpnt, dynamic_info, NULL, lib_loadaddr);
  621. /* If the TEXTREL is set, this means that we need to make the pages
  622. writable before we perform relocations. Do this now. They get set
  623. back again later. */
  624. if (dynamic_info[DT_TEXTREL]) {
  625. #ifndef __FORCE_SHAREABLE_TEXT_SEGMENTS__
  626. ppnt = (ElfW(Phdr) *)(intptr_t) & header[epnt->e_phoff];
  627. for (i = 0; i < epnt->e_phnum; i++, ppnt++) {
  628. if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W)) {
  629. #ifdef __ARCH_USE_MMU__
  630. _dl_mprotect((void *) ((piclib ? libaddr : lib_loadaddr) +
  631. (ppnt->p_vaddr & PAGE_ALIGN)),
  632. (ppnt->p_vaddr & ADDR_ALIGN) + (unsigned long) ppnt->p_filesz,
  633. PROT_READ | PROT_WRITE | PROT_EXEC);
  634. #else
  635. void *new_addr;
  636. new_addr = map_writeable (infile, ppnt, piclib, flags, libaddr);
  637. if (!new_addr) {
  638. _dl_dprintf(_dl_debug_file, "Can't modify %s's text section.",
  639. libname);
  640. _dl_exit(1);
  641. }
  642. DL_UPDATE_LOADADDR_HDR(lib_loadaddr,
  643. new_addr + (ppnt->p_vaddr & ADDR_ALIGN),
  644. ppnt);
  645. /* This has invalidated all pointers into the previously readonly segment.
  646. Update any them to point into the remapped segment. */
  647. _dl_parse_dynamic_info(dpnt, dynamic_info, NULL, lib_loadaddr);
  648. #endif
  649. }
  650. }
  651. #else
  652. _dl_dprintf(_dl_debug_file, "Can't modify %s's text section."
  653. " Use GCC option -fPIC for shared objects, please.\n",
  654. libname);
  655. _dl_exit(1);
  656. #endif
  657. }
  658. _dl_close(infile);
  659. tpnt = _dl_add_elf_hash_table(libname, lib_loadaddr, dynamic_info,
  660. dynamic_addr, 0);
  661. tpnt->mapaddr = libaddr;
  662. tpnt->relro_addr = relro_addr;
  663. tpnt->relro_size = relro_size;
  664. tpnt->st_dev = st.st_dev;
  665. tpnt->st_ino = st.st_ino;
  666. tpnt->ppnt = (ElfW(Phdr) *) DL_RELOC_ADDR(tpnt->mapaddr, epnt->e_phoff);
  667. tpnt->n_phent = epnt->e_phnum;
  668. tpnt->rtld_flags |= rtld_flags;
  669. #ifdef __LDSO_STANDALONE_SUPPORT__
  670. tpnt->l_entry = epnt->e_entry;
  671. #endif
  672. #if defined(USE_TLS) && USE_TLS
  673. if (tlsppnt) {
  674. _dl_debug_early("Found TLS header for %s\n", libname);
  675. # if NO_TLS_OFFSET != 0
  676. tpnt->l_tls_offset = NO_TLS_OFFSET;
  677. # endif
  678. tpnt->l_tls_blocksize = tlsppnt->p_memsz;
  679. tpnt->l_tls_align = tlsppnt->p_align;
  680. if (tlsppnt->p_align == 0)
  681. tpnt->l_tls_firstbyte_offset = 0;
  682. else
  683. tpnt->l_tls_firstbyte_offset = tlsppnt->p_vaddr &
  684. (tlsppnt->p_align - 1);
  685. tpnt->l_tls_initimage_size = tlsppnt->p_filesz;
  686. tpnt->l_tls_initimage = (void *) tlsppnt->p_vaddr;
  687. /* Assign the next available module ID. */
  688. tpnt->l_tls_modid = _dl_next_tls_modid ();
  689. /* We know the load address, so add it to the offset. */
  690. #ifdef __LDSO_STANDALONE_SUPPORT__
  691. if ((tpnt->l_tls_initimage != NULL) && piclib)
  692. #else
  693. if (tpnt->l_tls_initimage != NULL)
  694. #endif
  695. {
  696. # ifdef __SUPPORT_LD_DEBUG_EARLY__
  697. unsigned int tmp = (unsigned int) tpnt->l_tls_initimage;
  698. tpnt->l_tls_initimage = (char *) tlsppnt->p_vaddr + tpnt->loadaddr;
  699. _dl_debug_early("Relocated TLS initial image from %x to %x (size = %x)\n", tmp, tpnt->l_tls_initimage, tpnt->l_tls_initimage_size);
  700. tmp = 0;
  701. # else
  702. tpnt->l_tls_initimage = (char *) tlsppnt->p_vaddr + tpnt->loadaddr;
  703. # endif
  704. }
  705. }
  706. #endif
  707. /*
  708. * Add this object into the symbol chain
  709. */
  710. if (*rpnt
  711. #ifdef __LDSO_STANDALONE_SUPPORT__
  712. /* Do not create a new chain entry for the main executable */
  713. && (*rpnt)->dyn
  714. #endif
  715. ) {
  716. (*rpnt)->next = _dl_malloc(sizeof(struct dyn_elf));
  717. _dl_memset((*rpnt)->next, 0, sizeof(struct dyn_elf));
  718. (*rpnt)->next->prev = (*rpnt);
  719. *rpnt = (*rpnt)->next;
  720. }
  721. #ifndef SHARED
  722. /* When statically linked, the first time we dlopen a DSO
  723. * the *rpnt is NULL, so we need to allocate memory for it,
  724. * and initialize the _dl_symbol_table.
  725. */
  726. else {
  727. *rpnt = _dl_symbol_tables = _dl_malloc(sizeof(struct dyn_elf));
  728. _dl_memset(*rpnt, 0, sizeof(struct dyn_elf));
  729. }
  730. #endif
  731. (*rpnt)->dyn = tpnt;
  732. tpnt->usage_count++;
  733. #ifdef __LDSO_STANDALONE_SUPPORT__
  734. tpnt->libtype = (epnt->e_type == ET_DYN) ? elf_lib : elf_executable;
  735. #else
  736. tpnt->libtype = elf_lib;
  737. #endif
  738. /*
  739. * OK, the next thing we need to do is to insert the dynamic linker into
  740. * the proper entry in the GOT so that the PLT symbols can be properly
  741. * resolved.
  742. */
  743. lpnt = (unsigned long *) dynamic_info[DT_PLTGOT];
  744. if (lpnt) {
  745. lpnt = (unsigned long *) (dynamic_info[DT_PLTGOT]);
  746. INIT_GOT(lpnt, tpnt);
  747. }
  748. #ifdef __DSBT__
  749. /* Handle DSBT initialization */
  750. {
  751. struct elf_resolve *t, *ref;
  752. int idx = tpnt->loadaddr.map->dsbt_index;
  753. unsigned *dsbt = tpnt->loadaddr.map->dsbt_table;
  754. if (idx == 0) {
  755. if (!dynamic_info[DT_TEXTREL]) {
  756. /* This DSO has not been assigned an index. */
  757. _dl_dprintf(2, "%s: '%s' is missing a dsbt index assignment!\n",
  758. _dl_progname, libname);
  759. _dl_exit(1);
  760. }
  761. /* Find a dsbt table from another module. */
  762. ref = NULL;
  763. for (t = _dl_loaded_modules; t; t = t->next) {
  764. if (ref == NULL && t != tpnt) {
  765. ref = t;
  766. break;
  767. }
  768. }
  769. idx = tpnt->loadaddr.map->dsbt_size;
  770. while (idx-- > 0)
  771. if (!ref || ref->loadaddr.map->dsbt_table[idx] == NULL)
  772. break;
  773. if (idx <= 0) {
  774. _dl_dprintf(2, "%s: '%s' caused DSBT table overflow!\n",
  775. _dl_progname, libname);
  776. _dl_exit(1);
  777. }
  778. _dl_if_debug_dprint("\n\tfile='%s'; assigned index %d\n",
  779. libname, idx);
  780. tpnt->loadaddr.map->dsbt_index = idx;
  781. }
  782. /*
  783. * Setup dsbt slot for this module in dsbt of all modules.
  784. */
  785. ref = NULL;
  786. for (t = _dl_loaded_modules; t; t = t->next) {
  787. /* find a dsbt table from another module */
  788. if (ref == NULL && t != tpnt) {
  789. ref = t;
  790. /* make sure index is not already used */
  791. if (t->loadaddr.map->dsbt_table[idx]) {
  792. struct elf_resolve *dup;
  793. char *dup_name;
  794. for (dup = _dl_loaded_modules; dup; dup = dup->next)
  795. if (dup != tpnt && dup->loadaddr.map->dsbt_index == idx)
  796. break;
  797. if (dup)
  798. dup_name = dup->libname;
  799. else if (idx == 1)
  800. dup_name = "runtime linker";
  801. else
  802. dup_name = "unknown library";
  803. _dl_dprintf(2, "%s: '%s' dsbt index %d already used by %s!\n",
  804. _dl_progname, libname, idx, dup_name);
  805. _dl_exit(1);
  806. }
  807. }
  808. t->loadaddr.map->dsbt_table[idx] = (unsigned)dsbt;
  809. }
  810. if (ref)
  811. _dl_memcpy(dsbt, ref->loadaddr.map->dsbt_table,
  812. tpnt->loadaddr.map->dsbt_size * sizeof(unsigned *));
  813. }
  814. #endif
  815. _dl_if_debug_dprint("\n\tfile='%s'; generating link map\n", libname);
  816. _dl_if_debug_dprint("\t\tdynamic: %x base: %x\n", dynamic_addr, DL_LOADADDR_BASE(lib_loadaddr));
  817. _dl_if_debug_dprint("\t\t entry: %x phdr: %x phnum: %x\n\n",
  818. DL_RELOC_ADDR(lib_loadaddr, epnt->e_entry), tpnt->ppnt, tpnt->n_phent);
  819. _dl_munmap(header, _dl_pagesize);
  820. return tpnt;
  821. }
  822. /* now_flag must be RTLD_NOW or zero */
  823. int _dl_fixup(struct dyn_elf *rpnt, struct r_scope_elem *scope, int now_flag)
  824. {
  825. int goof = 0;
  826. struct elf_resolve *tpnt;
  827. ElfW(Word) reloc_size, relative_count;
  828. ElfW(Addr) reloc_addr;
  829. if (rpnt->next)
  830. goof = _dl_fixup(rpnt->next, scope, now_flag);
  831. if (goof)
  832. return goof;
  833. tpnt = rpnt->dyn;
  834. if (!(tpnt->init_flag & RELOCS_DONE))
  835. _dl_if_debug_dprint("relocation processing: %s\n", tpnt->libname);
  836. if (unlikely(tpnt->dynamic_info[UNSUPPORTED_RELOC_TYPE])) {
  837. _dl_if_debug_dprint("%s: can't handle %s relocation records\n",
  838. _dl_progname, UNSUPPORTED_RELOC_STR);
  839. goof++;
  840. return goof;
  841. }
  842. reloc_size = tpnt->dynamic_info[DT_RELOC_TABLE_SIZE];
  843. /* On some machines, notably SPARC & PPC, DT_REL* includes DT_JMPREL in its
  844. range. Note that according to the ELF spec, this is completely legal! */
  845. #ifdef ELF_MACHINE_PLTREL_OVERLAP
  846. reloc_size -= tpnt->dynamic_info [DT_PLTRELSZ];
  847. #endif
  848. if (tpnt->dynamic_info[DT_RELOC_TABLE_ADDR] &&
  849. !(tpnt->init_flag & RELOCS_DONE)) {
  850. reloc_addr = tpnt->dynamic_info[DT_RELOC_TABLE_ADDR];
  851. relative_count = tpnt->dynamic_info[DT_RELCONT_IDX];
  852. if (relative_count) { /* Optimize the XX_RELATIVE relocations if possible */
  853. reloc_size -= relative_count * sizeof(ELF_RELOC);
  854. if (tpnt->loadaddr
  855. #ifdef __LDSO_PRELINK_SUPPORT__
  856. || (!tpnt->dynamic_info[DT_GNU_PRELINKED_IDX])
  857. #endif
  858. )
  859. elf_machine_relative(tpnt->loadaddr, reloc_addr, relative_count);
  860. reloc_addr += relative_count * sizeof(ELF_RELOC);
  861. }
  862. goof += _dl_parse_relocation_information(rpnt, scope,
  863. reloc_addr,
  864. reloc_size);
  865. tpnt->init_flag |= RELOCS_DONE;
  866. }
  867. if (tpnt->dynamic_info[DT_BIND_NOW])
  868. now_flag = RTLD_NOW;
  869. if (tpnt->dynamic_info[DT_JMPREL] &&
  870. (!(tpnt->init_flag & JMP_RELOCS_DONE) ||
  871. (now_flag && !(tpnt->rtld_flags & now_flag)))) {
  872. tpnt->rtld_flags |= now_flag;
  873. if (!(tpnt->rtld_flags & RTLD_NOW)) {
  874. _dl_parse_lazy_relocation_information(rpnt,
  875. tpnt->dynamic_info[DT_JMPREL],
  876. tpnt->dynamic_info [DT_PLTRELSZ]);
  877. } else {
  878. goof += _dl_parse_relocation_information(rpnt, scope,
  879. tpnt->dynamic_info[DT_JMPREL],
  880. tpnt->dynamic_info[DT_PLTRELSZ]);
  881. }
  882. tpnt->init_flag |= JMP_RELOCS_DONE;
  883. }
  884. #if 0
  885. /* _dl_add_to_slotinfo is called by init_tls() for initial DSO
  886. or by dlopen() for dynamically loaded DSO. */
  887. #if defined(USE_TLS) && USE_TLS
  888. /* Add object to slot information data if necessasy. */
  889. if (tpnt->l_tls_blocksize != 0 && tls_init_tp_called)
  890. _dl_add_to_slotinfo ((struct link_map *) tpnt);
  891. #endif
  892. #endif
  893. return goof;
  894. }
  895. /* Minimal printf which handles only %s, %d, and %x */
  896. void _dl_dprintf(int fd, const char *fmt, ...)
  897. {
  898. #if __WORDSIZE > 32
  899. long int num;
  900. #else
  901. int num;
  902. #endif
  903. va_list args;
  904. char *start, *ptr, *string;
  905. char *buf;
  906. if (!fmt)
  907. return;
  908. buf = _dl_mmap((void *) 0, _dl_pagesize, PROT_READ | PROT_WRITE,
  909. MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  910. if (_dl_mmap_check_error(buf)) {
  911. _dl_write(fd, "mmap of a spare page failed!\n", 29);
  912. _dl_exit(20);
  913. }
  914. start = ptr = buf;
  915. if (_dl_strlen(fmt) >= (_dl_pagesize - 1)) {
  916. _dl_write(fd, "overflow\n", 11);
  917. _dl_exit(20);
  918. }
  919. _dl_strcpy(buf, fmt);
  920. va_start(args, fmt);
  921. while (start) {
  922. while (*ptr != '%' && *ptr) {
  923. ptr++;
  924. }
  925. if (*ptr == '%') {
  926. *ptr++ = '\0';
  927. _dl_write(fd, start, _dl_strlen(start));
  928. switch (*ptr++) {
  929. case 's':
  930. string = va_arg(args, char *);
  931. if (!string)
  932. _dl_write(fd, "(null)", 6);
  933. else
  934. _dl_write(fd, string, _dl_strlen(string));
  935. break;
  936. case 'i':
  937. case 'd':
  938. {
  939. char tmp[22];
  940. #if __WORDSIZE > 32
  941. num = va_arg(args, long int);
  942. #else
  943. num = va_arg(args, int);
  944. #endif
  945. string = _dl_simple_ltoa(tmp, num);
  946. _dl_write(fd, string, _dl_strlen(string));
  947. break;
  948. }
  949. case 'x':
  950. case 'X':
  951. {
  952. char tmp[22];
  953. #if __WORDSIZE > 32
  954. num = va_arg(args, long int);
  955. #else
  956. num = va_arg(args, int);
  957. #endif
  958. string = _dl_simple_ltoahex(tmp, num);
  959. _dl_write(fd, string, _dl_strlen(string));
  960. break;
  961. }
  962. default:
  963. _dl_write(fd, "(null)", 6);
  964. break;
  965. }
  966. start = ptr;
  967. } else {
  968. _dl_write(fd, start, _dl_strlen(start));
  969. start = NULL;
  970. }
  971. }
  972. _dl_munmap(buf, _dl_pagesize);
  973. return;
  974. }
  975. char *_dl_strdup(const char *string)
  976. {
  977. char *retval;
  978. int len;
  979. len = _dl_strlen(string);
  980. retval = _dl_malloc(len + 1);
  981. _dl_strcpy(retval, string);
  982. return retval;
  983. }
  984. unsigned int _dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[],
  985. void *debug_addr, DL_LOADADDR_TYPE load_off)
  986. {
  987. return __dl_parse_dynamic_info(dpnt, dynamic_info, debug_addr, load_off);
  988. }