Juan Cespedes | d44c6b8 | 1998-09-25 14:48:42 +0200 | [diff] [blame] | 1 | #if HAVE_CONFIG_H |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 2 | # include "config.h" |
Juan Cespedes | d44c6b8 | 1998-09-25 14:48:42 +0200 | [diff] [blame] | 3 | #endif |
| 4 | |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 5 | #include <endian.h> |
Juan Cespedes | 96935a9 | 1997-08-09 23:45:39 +0200 | [diff] [blame] | 6 | #include <errno.h> |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 7 | #include <error.h> |
Juan Cespedes | 96935a9 | 1997-08-09 23:45:39 +0200 | [diff] [blame] | 8 | #include <fcntl.h> |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 9 | #include <gelf.h> |
| 10 | #include <stdint.h> |
| 11 | #include <stdlib.h> |
Juan Cespedes | 96935a9 | 1997-08-09 23:45:39 +0200 | [diff] [blame] | 12 | #include <string.h> |
Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 13 | #include <unistd.h> |
Juan Cespedes | 96935a9 | 1997-08-09 23:45:39 +0200 | [diff] [blame] | 14 | |
Juan Cespedes | 96935a9 | 1997-08-09 23:45:39 +0200 | [diff] [blame] | 15 | #include "ltrace.h" |
Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 16 | #include "elf.h" |
Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame] | 17 | #include "debug.h" |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 18 | #include "options.h" |
Juan Cespedes | 96935a9 | 1997-08-09 23:45:39 +0200 | [diff] [blame] | 19 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 20 | static void do_init_elf(struct ltelf *lte, const char *filename); |
| 21 | static void do_close_elf(struct ltelf *lte); |
| 22 | static void add_library_symbol(GElf_Addr addr, const char *name, |
| 23 | struct library_symbol **library_symbolspp, |
Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 24 | enum toplt type_of_plt, int is_weak); |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 25 | static int in_load_libraries(const char *name, struct ltelf *lte); |
Ian Wienand | 4bfcedd | 2006-08-07 04:03:15 +0200 | [diff] [blame] | 26 | static GElf_Addr opd2addr(struct ltelf *ltc, GElf_Addr addr); |
Juan Cespedes | 1cd999a | 2001-07-03 00:46:04 +0200 | [diff] [blame] | 27 | |
Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 28 | #ifdef PLT_REINITALISATION_BP |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 29 | extern char *PLTs_initialized_by_here; |
Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 30 | #endif |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 31 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 32 | static void do_init_elf(struct ltelf *lte, const char *filename) |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 33 | { |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 34 | int i; |
| 35 | GElf_Addr relplt_addr = 0; |
| 36 | size_t relplt_size = 0; |
Juan Cespedes | 1cd999a | 2001-07-03 00:46:04 +0200 | [diff] [blame] | 37 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 38 | debug(1, "Reading ELF from %s...", filename); |
Juan Cespedes | 1afec69 | 1997-08-23 21:31:46 +0200 | [diff] [blame] | 39 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 40 | memset(lte, 0, sizeof(*lte)); |
| 41 | lte->fd = open(filename, O_RDONLY); |
| 42 | if (lte->fd == -1) |
| 43 | error(EXIT_FAILURE, errno, "Can't open \"%s\"", filename); |
Juan Cespedes | 96935a9 | 1997-08-09 23:45:39 +0200 | [diff] [blame] | 44 | |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 45 | #ifdef HAVE_ELF_C_READ_MMAP |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 46 | lte->elf = elf_begin(lte->fd, ELF_C_READ_MMAP, NULL); |
Juan Cespedes | 5c3fe06 | 2004-06-14 18:08:37 +0200 | [diff] [blame] | 47 | #else |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 48 | lte->elf = elf_begin(lte->fd, ELF_C_READ, NULL); |
Juan Cespedes | 5c3fe06 | 2004-06-14 18:08:37 +0200 | [diff] [blame] | 49 | #endif |
Juan Cespedes | 1cd999a | 2001-07-03 00:46:04 +0200 | [diff] [blame] | 50 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 51 | if (lte->elf == NULL || elf_kind(lte->elf) != ELF_K_ELF) |
| 52 | error(EXIT_FAILURE, 0, "Can't open ELF file \"%s\"", filename); |
Juan Cespedes | 1cd999a | 2001-07-03 00:46:04 +0200 | [diff] [blame] | 53 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 54 | if (gelf_getehdr(lte->elf, <e->ehdr) == NULL) |
| 55 | error(EXIT_FAILURE, 0, "Can't read ELF header of \"%s\"", |
| 56 | filename); |
Juan Cespedes | 1cd999a | 2001-07-03 00:46:04 +0200 | [diff] [blame] | 57 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 58 | if (lte->ehdr.e_type != ET_EXEC && lte->ehdr.e_type != ET_DYN) |
| 59 | error(EXIT_FAILURE, 0, |
| 60 | "\"%s\" is not an ELF executable nor shared library", |
| 61 | filename); |
Juan Cespedes | 1cd999a | 2001-07-03 00:46:04 +0200 | [diff] [blame] | 62 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 63 | if ((lte->ehdr.e_ident[EI_CLASS] != LT_ELFCLASS |
| 64 | || lte->ehdr.e_machine != LT_ELF_MACHINE) |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 65 | #ifdef LT_ELF_MACHINE2 |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 66 | && (lte->ehdr.e_ident[EI_CLASS] != LT_ELFCLASS2 |
| 67 | || lte->ehdr.e_machine != LT_ELF_MACHINE2) |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 68 | #endif |
| 69 | #ifdef LT_ELF_MACHINE3 |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 70 | && (lte->ehdr.e_ident[EI_CLASS] != LT_ELFCLASS3 |
| 71 | || lte->ehdr.e_machine != LT_ELF_MACHINE3) |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 72 | #endif |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 73 | ) |
| 74 | error(EXIT_FAILURE, 0, |
| 75 | "\"%s\" is ELF from incompatible architecture", filename); |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 76 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 77 | for (i = 1; i < lte->ehdr.e_shnum; ++i) { |
| 78 | Elf_Scn *scn; |
| 79 | GElf_Shdr shdr; |
| 80 | const char *name; |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 81 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 82 | scn = elf_getscn(lte->elf, i); |
| 83 | if (scn == NULL || gelf_getshdr(scn, &shdr) == NULL) |
| 84 | error(EXIT_FAILURE, 0, |
| 85 | "Couldn't get section header from \"%s\"", |
| 86 | filename); |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 87 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 88 | name = elf_strptr(lte->elf, lte->ehdr.e_shstrndx, shdr.sh_name); |
| 89 | if (name == NULL) |
| 90 | error(EXIT_FAILURE, 0, |
| 91 | "Couldn't get section header from \"%s\"", |
| 92 | filename); |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 93 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 94 | if (shdr.sh_type == SHT_SYMTAB) { |
| 95 | Elf_Data *data; |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 96 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 97 | lte->symtab = elf_getdata(scn, NULL); |
| 98 | lte->symtab_count = shdr.sh_size / shdr.sh_entsize; |
| 99 | if ((lte->symtab == NULL |
| 100 | || elf_getdata(scn, lte->symtab) != NULL) |
| 101 | && opt_x != NULL) |
| 102 | error(EXIT_FAILURE, 0, |
| 103 | "Couldn't get .symtab data from \"%s\"", |
| 104 | filename); |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 105 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 106 | scn = elf_getscn(lte->elf, shdr.sh_link); |
| 107 | if (scn == NULL || gelf_getshdr(scn, &shdr) == NULL) |
| 108 | error(EXIT_FAILURE, 0, |
| 109 | "Couldn't get section header from \"%s\"", |
| 110 | filename); |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 111 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 112 | data = elf_getdata(scn, NULL); |
| 113 | if (data == NULL || elf_getdata(scn, data) != NULL |
| 114 | || shdr.sh_size != data->d_size || data->d_off) |
| 115 | error(EXIT_FAILURE, 0, |
| 116 | "Couldn't get .strtab data from \"%s\"", |
| 117 | filename); |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 118 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 119 | lte->strtab = data->d_buf; |
| 120 | } else if (shdr.sh_type == SHT_DYNSYM) { |
| 121 | Elf_Data *data; |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 122 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 123 | lte->dynsym = elf_getdata(scn, NULL); |
| 124 | lte->dynsym_count = shdr.sh_size / shdr.sh_entsize; |
| 125 | if (lte->dynsym == NULL |
| 126 | || elf_getdata(scn, lte->dynsym) != NULL) |
| 127 | error(EXIT_FAILURE, 0, |
| 128 | "Couldn't get .dynsym data from \"%s\"", |
| 129 | filename); |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 130 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 131 | scn = elf_getscn(lte->elf, shdr.sh_link); |
| 132 | if (scn == NULL || gelf_getshdr(scn, &shdr) == NULL) |
| 133 | error(EXIT_FAILURE, 0, |
| 134 | "Couldn't get section header from \"%s\"", |
| 135 | filename); |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 136 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 137 | data = elf_getdata(scn, NULL); |
| 138 | if (data == NULL || elf_getdata(scn, data) != NULL |
| 139 | || shdr.sh_size != data->d_size || data->d_off) |
| 140 | error(EXIT_FAILURE, 0, |
| 141 | "Couldn't get .dynstr data from \"%s\"", |
| 142 | filename); |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 143 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 144 | lte->dynstr = data->d_buf; |
| 145 | } else if (shdr.sh_type == SHT_DYNAMIC) { |
| 146 | Elf_Data *data; |
| 147 | size_t j; |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 148 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 149 | data = elf_getdata(scn, NULL); |
| 150 | if (data == NULL || elf_getdata(scn, data) != NULL) |
| 151 | error(EXIT_FAILURE, 0, |
| 152 | "Couldn't get .dynamic data from \"%s\"", |
| 153 | filename); |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 154 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 155 | for (j = 0; j < shdr.sh_size / shdr.sh_entsize; ++j) { |
| 156 | GElf_Dyn dyn; |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 157 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 158 | if (gelf_getdyn(data, j, &dyn) == NULL) |
| 159 | error(EXIT_FAILURE, 0, |
| 160 | "Couldn't get .dynamic data from \"%s\"", |
| 161 | filename); |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 162 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 163 | if (dyn.d_tag == DT_JMPREL) |
| 164 | relplt_addr = dyn.d_un.d_ptr; |
| 165 | else if (dyn.d_tag == DT_PLTRELSZ) |
| 166 | relplt_size = dyn.d_un.d_val; |
| 167 | } |
| 168 | } else if (shdr.sh_type == SHT_HASH) { |
| 169 | Elf_Data *data; |
| 170 | size_t j; |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 171 | |
Petr Machata | 35fe518 | 2006-07-18 12:58:12 +0200 | [diff] [blame] | 172 | lte->hash_type = SHT_HASH; |
| 173 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 174 | data = elf_getdata(scn, NULL); |
| 175 | if (data == NULL || elf_getdata(scn, data) != NULL |
| 176 | || data->d_off || data->d_size != shdr.sh_size) |
| 177 | error(EXIT_FAILURE, 0, |
| 178 | "Couldn't get .hash data from \"%s\"", |
| 179 | filename); |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 180 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 181 | if (shdr.sh_entsize == 4) { |
| 182 | /* Standard conforming ELF. */ |
| 183 | if (data->d_type != ELF_T_WORD) |
| 184 | error(EXIT_FAILURE, 0, |
| 185 | "Couldn't get .hash data from \"%s\"", |
| 186 | filename); |
| 187 | lte->hash = (Elf32_Word *) data->d_buf; |
| 188 | } else if (shdr.sh_entsize == 8) { |
| 189 | /* Alpha or s390x. */ |
| 190 | Elf32_Word *dst, *src; |
| 191 | size_t hash_count = data->d_size / 8; |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 192 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 193 | lte->hash = (Elf32_Word *) |
| 194 | malloc(hash_count * sizeof(Elf32_Word)); |
| 195 | if (lte->hash == NULL) |
| 196 | error(EXIT_FAILURE, 0, |
| 197 | "Couldn't convert .hash section from \"%s\"", |
| 198 | filename); |
Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 199 | lte->lte_flags |= LTE_HASH_MALLOCED; |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 200 | dst = lte->hash; |
| 201 | src = (Elf32_Word *) data->d_buf; |
| 202 | if ((data->d_type == ELF_T_WORD |
| 203 | && __BYTE_ORDER == __BIG_ENDIAN) |
| 204 | || (data->d_type == ELF_T_XWORD |
| 205 | && lte->ehdr.e_ident[EI_DATA] == |
| 206 | ELFDATA2MSB)) |
| 207 | ++src; |
| 208 | for (j = 0; j < hash_count; ++j, src += 2) |
| 209 | *dst++ = *src; |
| 210 | } else |
| 211 | error(EXIT_FAILURE, 0, |
| 212 | "Unknown .hash sh_entsize in \"%s\"", |
| 213 | filename); |
Petr Machata | 35fe518 | 2006-07-18 12:58:12 +0200 | [diff] [blame] | 214 | } else if (shdr.sh_type == SHT_GNU_HASH |
| 215 | && lte->hash == NULL) { |
| 216 | Elf_Data *data; |
Petr Machata | 35fe518 | 2006-07-18 12:58:12 +0200 | [diff] [blame] | 217 | |
| 218 | lte->hash_type = SHT_GNU_HASH; |
| 219 | |
| 220 | if (shdr.sh_entsize != 0 |
| 221 | && shdr.sh_entsize != 4) { |
| 222 | error(EXIT_FAILURE, 0, |
Olaf Hering | 03c087b | 2006-09-25 02:31:27 +0200 | [diff] [blame^] | 223 | ".gnu.hash sh_entsize in \"%s\" should be 4, but is %llu", |
Petr Machata | 35fe518 | 2006-07-18 12:58:12 +0200 | [diff] [blame] | 224 | filename, shdr.sh_entsize); |
| 225 | } |
| 226 | |
| 227 | data = elf_getdata(scn, NULL); |
| 228 | if (data == NULL || elf_getdata(scn, data) != NULL |
| 229 | || data->d_off || data->d_size != shdr.sh_size) |
| 230 | error(EXIT_FAILURE, 0, |
| 231 | "Couldn't get .gnu.hash data from \"%s\"", |
| 232 | filename); |
| 233 | |
| 234 | lte->hash = (Elf32_Word *) data->d_buf; |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 235 | } else if (shdr.sh_type == SHT_PROGBITS |
| 236 | || shdr.sh_type == SHT_NOBITS) { |
| 237 | if (strcmp(name, ".plt") == 0) { |
| 238 | lte->plt_addr = shdr.sh_addr; |
| 239 | lte->plt_size = shdr.sh_size; |
Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 240 | if (shdr.sh_flags & SHF_EXECINSTR) { |
| 241 | lte->lte_flags |= LTE_PLT_EXECUTABLE; |
| 242 | } |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 243 | } else if (strcmp(name, ".opd") == 0) { |
Paul Gilliam | 3f1219f | 2006-04-24 18:25:38 +0200 | [diff] [blame] | 244 | lte->opd_addr = (GElf_Addr *) (long) shdr.sh_addr; |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 245 | lte->opd_size = shdr.sh_size; |
| 246 | lte->opd = elf_rawdata(scn, NULL); |
| 247 | } |
| 248 | } |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 249 | } |
| 250 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 251 | if (lte->dynsym == NULL || lte->dynstr == NULL) |
| 252 | error(EXIT_FAILURE, 0, |
| 253 | "Couldn't find .dynsym or .dynstr in \"%s\"", filename); |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 254 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 255 | if (!relplt_addr || !lte->plt_addr) { |
| 256 | debug(1, "%s has no PLT relocations", filename); |
| 257 | lte->relplt = NULL; |
| 258 | lte->relplt_count = 0; |
| 259 | } else { |
| 260 | for (i = 1; i < lte->ehdr.e_shnum; ++i) { |
| 261 | Elf_Scn *scn; |
| 262 | GElf_Shdr shdr; |
| 263 | |
| 264 | scn = elf_getscn(lte->elf, i); |
| 265 | if (scn == NULL || gelf_getshdr(scn, &shdr) == NULL) |
| 266 | error(EXIT_FAILURE, 0, |
| 267 | "Couldn't get section header from \"%s\"", |
| 268 | filename); |
| 269 | if (shdr.sh_addr == relplt_addr |
| 270 | && shdr.sh_size == relplt_size) { |
| 271 | lte->relplt = elf_getdata(scn, NULL); |
| 272 | lte->relplt_count = |
| 273 | shdr.sh_size / shdr.sh_entsize; |
| 274 | if (lte->relplt == NULL |
| 275 | || elf_getdata(scn, lte->relplt) != NULL) |
| 276 | error(EXIT_FAILURE, 0, |
| 277 | "Couldn't get .rel*.plt data from \"%s\"", |
| 278 | filename); |
| 279 | break; |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | if (i == lte->ehdr.e_shnum) |
| 284 | error(EXIT_FAILURE, 0, |
| 285 | "Couldn't find .rel*.plt section in \"%s\"", |
| 286 | filename); |
| 287 | |
| 288 | debug(1, "%s %zd PLT relocations", filename, lte->relplt_count); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | static void do_close_elf(struct ltelf *lte) |
| 293 | { |
Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 294 | if (lte->lte_flags & LTE_HASH_MALLOCED) |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 295 | free((char *)lte->hash); |
| 296 | elf_end(lte->elf); |
| 297 | close(lte->fd); |
Juan Cespedes | 1cd999a | 2001-07-03 00:46:04 +0200 | [diff] [blame] | 298 | } |
| 299 | |
Juan Cespedes | 8cc1b9d | 2002-03-01 19:54:23 +0100 | [diff] [blame] | 300 | static void |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 301 | add_library_symbol(GElf_Addr addr, const char *name, |
| 302 | struct library_symbol **library_symbolspp, |
Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 303 | enum toplt type_of_plt, int is_weak) |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 304 | { |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 305 | struct library_symbol *s; |
| 306 | s = malloc(sizeof(struct library_symbol) + strlen(name) + 1); |
| 307 | if (s == NULL) |
| 308 | error(EXIT_FAILURE, errno, "add_library_symbol failed"); |
| 309 | |
| 310 | s->needs_init = 1; |
| 311 | s->is_weak = is_weak; |
Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 312 | s->plt_type = type_of_plt; |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 313 | s->next = *library_symbolspp; |
| 314 | s->enter_addr = (void *)(uintptr_t) addr; |
| 315 | s->brkpnt = NULL; |
| 316 | s->name = (char *)(s + 1); |
| 317 | strcpy(s->name, name); |
| 318 | *library_symbolspp = s; |
| 319 | |
| 320 | debug(2, "addr: %p, symbol: \"%s\"", (void *)(uintptr_t) addr, name); |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 321 | } |
Juan Cespedes | 1cd999a | 2001-07-03 00:46:04 +0200 | [diff] [blame] | 322 | |
Olaf Hering | 03c087b | 2006-09-25 02:31:27 +0200 | [diff] [blame^] | 323 | /* stolen from elfutils-0.123 */ |
| 324 | static unsigned long elf_gnu_hash(const char *name) |
| 325 | { |
| 326 | unsigned long h = 5381; |
| 327 | const unsigned char *string = (const unsigned char *)name; |
| 328 | unsigned char c; |
| 329 | for (c = *string; c; c = *++string) |
| 330 | h = h * 33 + c; |
| 331 | return h & 0xffffffff; |
| 332 | } |
| 333 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 334 | static int in_load_libraries(const char *name, struct ltelf *lte) |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 335 | { |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 336 | size_t i; |
| 337 | unsigned long hash; |
Petr Machata | 35fe518 | 2006-07-18 12:58:12 +0200 | [diff] [blame] | 338 | unsigned long gnu_hash; |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 339 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 340 | if (!library_num) |
| 341 | return 1; |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 342 | |
Paul Gilliam | 3f1219f | 2006-04-24 18:25:38 +0200 | [diff] [blame] | 343 | hash = elf_hash((const unsigned char *)name); |
Olaf Hering | 03c087b | 2006-09-25 02:31:27 +0200 | [diff] [blame^] | 344 | gnu_hash = elf_gnu_hash(name); |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 345 | for (i = 1; i <= library_num; ++i) { |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 346 | if (lte[i].hash == NULL) |
| 347 | continue; |
Juan Cespedes | 1cd999a | 2001-07-03 00:46:04 +0200 | [diff] [blame] | 348 | |
Petr Machata | 35fe518 | 2006-07-18 12:58:12 +0200 | [diff] [blame] | 349 | if (lte[i].hash_type == SHT_GNU_HASH) { |
| 350 | Elf32_Word * hashbase = lte[i].hash; |
| 351 | Elf32_Word nbuckets = *hashbase++; |
| 352 | Elf32_Word symbias = *hashbase++; |
| 353 | Elf32_Word bitmask_nwords = *hashbase++; |
| 354 | Elf32_Word bitmask_idxbits = bitmask_nwords - 1; |
| 355 | Elf32_Word shift = *hashbase++; |
| 356 | Elf32_Word * buckets; |
| 357 | Elf32_Word * chain_zero; |
| 358 | Elf32_Word bucket; |
Juan Cespedes | 1cd999a | 2001-07-03 00:46:04 +0200 | [diff] [blame] | 359 | |
Petr Machata | 35fe518 | 2006-07-18 12:58:12 +0200 | [diff] [blame] | 360 | hashbase += lte[i].ehdr.e_ident[EI_CLASS] * bitmask_nwords; |
| 361 | buckets = hashbase; |
| 362 | hashbase += nbuckets; |
| 363 | chain_zero = hashbase - symbias; |
| 364 | bucket = buckets[gnu_hash % nbuckets]; |
Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 365 | |
Petr Machata | 35fe518 | 2006-07-18 12:58:12 +0200 | [diff] [blame] | 366 | if (bucket != 0) { |
| 367 | const Elf32_Word *hasharr = &chain_zero[bucket]; |
| 368 | do |
| 369 | if ((*hasharr & ~1u) == (gnu_hash & ~1u)) { |
| 370 | int symidx = hasharr - chain_zero; |
| 371 | GElf_Sym sym; |
| 372 | |
| 373 | if (gelf_getsym(lte[i].dynsym, symidx, &sym) == NULL) |
| 374 | error(EXIT_FAILURE, 0, |
| 375 | "Couldn't get symbol from .dynsym"); |
| 376 | |
| 377 | if (sym.st_value != 0 |
| 378 | && sym.st_shndx != SHN_UNDEF |
| 379 | && strcmp(name, lte[i].dynstr + sym.st_name) == 0) |
| 380 | return 1; |
| 381 | } |
| 382 | while ((*hasharr++ & 1u) == 0); |
| 383 | } |
Olaf Hering | 03c087b | 2006-09-25 02:31:27 +0200 | [diff] [blame^] | 384 | } else { |
Petr Machata | 35fe518 | 2006-07-18 12:58:12 +0200 | [diff] [blame] | 385 | Elf32_Word nbuckets, symndx; |
| 386 | Elf32_Word *buckets, *chain; |
| 387 | nbuckets = lte[i].hash[0]; |
| 388 | buckets = <e[i].hash[2]; |
| 389 | chain = <e[i].hash[2 + nbuckets]; |
| 390 | |
| 391 | for (symndx = buckets[hash % nbuckets]; |
| 392 | symndx != STN_UNDEF; symndx = chain[symndx]) { |
| 393 | GElf_Sym sym; |
| 394 | |
| 395 | if (gelf_getsym(lte[i].dynsym, symndx, &sym) == NULL) |
| 396 | error(EXIT_FAILURE, 0, |
| 397 | "Couldn't get symbol from .dynsym"); |
| 398 | |
| 399 | if (sym.st_value != 0 |
| 400 | && sym.st_shndx != SHN_UNDEF |
| 401 | && strcmp(name, lte[i].dynstr + sym.st_name) == 0) |
| 402 | return 1; |
| 403 | } |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 404 | } |
Juan Cespedes | 1cd999a | 2001-07-03 00:46:04 +0200 | [diff] [blame] | 405 | } |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 406 | return 0; |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 407 | } |
Juan Cespedes | 1cd999a | 2001-07-03 00:46:04 +0200 | [diff] [blame] | 408 | |
Ian Wienand | 4bfcedd | 2006-08-07 04:03:15 +0200 | [diff] [blame] | 409 | static GElf_Addr opd2addr(struct ltelf *lte, GElf_Addr addr) |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 410 | { |
Ian Wienand | 4bfcedd | 2006-08-07 04:03:15 +0200 | [diff] [blame] | 411 | unsigned long base, offset; |
Juan Cespedes | 1cd999a | 2001-07-03 00:46:04 +0200 | [diff] [blame] | 412 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 413 | if (!lte->opd) |
Ian Wienand | 4bfcedd | 2006-08-07 04:03:15 +0200 | [diff] [blame] | 414 | return addr; |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 415 | |
Ian Wienand | 4bfcedd | 2006-08-07 04:03:15 +0200 | [diff] [blame] | 416 | base = (unsigned long)lte->opd->d_buf; |
| 417 | offset = (unsigned long)addr - (unsigned long)lte->opd_addr; |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 418 | if (offset > lte->opd_size) |
| 419 | error(EXIT_FAILURE, 0, "static plt not in .opd"); |
| 420 | |
Olaf Hering | a841f65 | 2006-09-15 01:57:49 +0200 | [diff] [blame] | 421 | return *(GElf_Addr*)(base + offset); |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 422 | } |
| 423 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 424 | struct library_symbol *read_elf(struct process *proc) |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 425 | { |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 426 | struct library_symbol *library_symbols = NULL; |
| 427 | struct ltelf lte[MAX_LIBRARY + 1]; |
| 428 | size_t i; |
Paul Gilliam | 24e643a | 2006-03-13 18:43:13 +0100 | [diff] [blame] | 429 | struct opt_x_t *xptr; |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 430 | struct library_symbol **lib_tail = NULL; |
Paul Gilliam | 24e643a | 2006-03-13 18:43:13 +0100 | [diff] [blame] | 431 | int exit_out = 0; |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 432 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 433 | elf_version(EV_CURRENT); |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 434 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 435 | do_init_elf(lte, proc->filename); |
| 436 | proc->e_machine = lte->ehdr.e_machine; |
| 437 | for (i = 0; i < library_num; ++i) |
| 438 | do_init_elf(<e[i + 1], library[i]); |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 439 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 440 | for (i = 0; i < lte->relplt_count; ++i) { |
| 441 | GElf_Rel rel; |
| 442 | GElf_Rela rela; |
| 443 | GElf_Sym sym; |
| 444 | GElf_Addr addr; |
| 445 | void *ret; |
| 446 | const char *name; |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 447 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 448 | if (lte->relplt->d_type == ELF_T_REL) { |
| 449 | ret = gelf_getrel(lte->relplt, i, &rel); |
| 450 | rela.r_offset = rel.r_offset; |
| 451 | rela.r_info = rel.r_info; |
| 452 | rela.r_addend = 0; |
| 453 | } else |
| 454 | ret = gelf_getrela(lte->relplt, i, &rela); |
| 455 | |
| 456 | if (ret == NULL |
| 457 | || ELF64_R_SYM(rela.r_info) >= lte->dynsym_count |
| 458 | || gelf_getsym(lte->dynsym, ELF64_R_SYM(rela.r_info), |
| 459 | &sym) == NULL) |
| 460 | error(EXIT_FAILURE, 0, |
| 461 | "Couldn't get relocation from \"%s\"", |
| 462 | proc->filename); |
| 463 | |
Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 464 | #ifdef PLT_REINITALISATION_BP |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 465 | if (!sym.st_value && PLTs_initialized_by_here) |
| 466 | proc->need_to_reinitialize_breakpoints = 1; |
Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 467 | #endif |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 468 | |
| 469 | name = lte->dynstr + sym.st_name; |
| 470 | if (in_load_libraries(name, lte)) { |
| 471 | addr = arch_plt_sym_val(lte, i, &rela); |
Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 472 | add_library_symbol(addr, name, &library_symbols, |
| 473 | (PLTS_ARE_EXECUTABLE(lte) |
| 474 | ? LS_TOPLT_EXEC : LS_TOPLT_POINT), |
Petr Machata | 7003fee | 2006-07-18 13:06:26 +0200 | [diff] [blame] | 475 | ELF64_ST_BIND(sym.st_info) == STB_WEAK); |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 476 | if (!lib_tail) |
| 477 | lib_tail = &(library_symbols->next); |
| 478 | } |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 479 | } |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 480 | |
Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 481 | #ifdef PLT_REINITALISATION_BP |
Ian Wienand | 4bfcedd | 2006-08-07 04:03:15 +0200 | [diff] [blame] | 482 | struct opt_x_t *main_cheat; |
| 483 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 484 | if (proc->need_to_reinitialize_breakpoints) { |
Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 485 | /* Add "PLTs_initialized_by_here" to opt_x list, if not |
| 486 | already there. */ |
Paul Gilliam | 2b2507a | 2006-04-07 18:32:07 +0200 | [diff] [blame] | 487 | main_cheat = (struct opt_x_t *)malloc(sizeof(struct opt_x_t)); |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 488 | if (main_cheat == NULL) |
Petr Machata | 7003fee | 2006-07-18 13:06:26 +0200 | [diff] [blame] | 489 | error(EXIT_FAILURE, 0, "Couldn't allocate memory"); |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 490 | main_cheat->next = opt_x; |
Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 491 | main_cheat->found = 0; |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 492 | main_cheat->name = PLTs_initialized_by_here; |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 493 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 494 | for (xptr = opt_x; xptr; xptr = xptr->next) |
| 495 | if (strcmp(xptr->name, PLTs_initialized_by_here) == 0 |
| 496 | && main_cheat) { |
| 497 | free(main_cheat); |
| 498 | main_cheat = NULL; |
| 499 | break; |
| 500 | } |
| 501 | if (main_cheat) |
| 502 | opt_x = main_cheat; |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 503 | } |
Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 504 | #endif |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 505 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 506 | for (i = 0; i < lte->symtab_count; ++i) { |
| 507 | GElf_Sym sym; |
| 508 | GElf_Addr addr; |
| 509 | const char *name; |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 510 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 511 | if (gelf_getsym(lte->symtab, i, &sym) == NULL) |
| 512 | error(EXIT_FAILURE, 0, |
| 513 | "Couldn't get symbol from \"%s\"", |
| 514 | proc->filename); |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 515 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 516 | name = lte->strtab + sym.st_name; |
| 517 | addr = sym.st_value; |
| 518 | if (!addr) |
| 519 | continue; |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 520 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 521 | for (xptr = opt_x; xptr; xptr = xptr->next) |
| 522 | if (xptr->name && strcmp(xptr->name, name) == 0) { |
| 523 | /* FIXME: Should be able to use &library_symbols as above. But |
| 524 | when you do, none of the real library symbols cause breaks. */ |
Ian Wienand | 4bfcedd | 2006-08-07 04:03:15 +0200 | [diff] [blame] | 525 | add_library_symbol(opd2addr(lte, addr), |
Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 526 | name, lib_tail, LS_TOPLT_NONE, 0); |
Paul Gilliam | 24e643a | 2006-03-13 18:43:13 +0100 | [diff] [blame] | 527 | xptr->found = 1; |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 528 | break; |
| 529 | } |
| 530 | } |
| 531 | for (xptr = opt_x; xptr; xptr = xptr->next) |
Paul Gilliam | 24e643a | 2006-03-13 18:43:13 +0100 | [diff] [blame] | 532 | if ( ! xptr->found) { |
| 533 | char *badthing = "WARNING"; |
Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 534 | #ifdef PLT_REINITALISATION_BP |
| 535 | if (strcmp(xptr->name, PLTs_initialized_by_here) == 0) { |
| 536 | if (lte->ehdr.e_entry) { |
| 537 | add_library_symbol ( |
Ian Wienand | 4bfcedd | 2006-08-07 04:03:15 +0200 | [diff] [blame] | 538 | opd2addr (lte, lte->ehdr.e_entry), |
Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 539 | PLTs_initialized_by_here, |
| 540 | lib_tail, 1, 0); |
| 541 | fprintf (stderr, "WARNING: Using e_ent" |
| 542 | "ry from elf header (%p) for " |
| 543 | "address of \"%s\"\n", (void*) |
| 544 | (long) lte->ehdr.e_entry, |
| 545 | PLTs_initialized_by_here); |
| 546 | continue; |
| 547 | } |
Paul Gilliam | 24e643a | 2006-03-13 18:43:13 +0100 | [diff] [blame] | 548 | badthing = "ERROR"; |
| 549 | exit_out = 1; |
| 550 | } |
Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 551 | #endif |
Paul Gilliam | 24e643a | 2006-03-13 18:43:13 +0100 | [diff] [blame] | 552 | fprintf (stderr, |
Paul Gilliam | be32077 | 2006-04-24 22:06:23 +0200 | [diff] [blame] | 553 | "%s: Couldn't find symbol \"%s\" in file \"%s" |
| 554 | "\"\n", badthing, xptr->name, proc->filename); |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 555 | } |
Paul Gilliam | 24e643a | 2006-03-13 18:43:13 +0100 | [diff] [blame] | 556 | if (exit_out) { |
| 557 | exit (1); |
| 558 | } |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 559 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 560 | for (i = 0; i < library_num + 1; ++i) |
| 561 | do_close_elf(<e[i]); |
Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 562 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 563 | return library_symbols; |
Juan Cespedes | 96935a9 | 1997-08-09 23:45:39 +0200 | [diff] [blame] | 564 | } |