Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is included twice from vdso2c.c. It generates code for 32-bit |
| 3 | * and 64-bit vDSOs. We need both for 64-bit builds, since 32-bit vDSOs |
| 4 | * are built for 32-bit userspace. |
| 5 | */ |
| 6 | |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame] | 7 | /* |
| 8 | * We're writing a section table for a few reasons: |
| 9 | * |
| 10 | * The Go runtime had a couple of bugs: it would read the section |
| 11 | * table to try to figure out how many dynamic symbols there were (it |
| 12 | * shouldn't have looked at the section table at all) and, if there |
| 13 | * were no SHT_SYNDYM section table entry, it would use an |
| 14 | * uninitialized value for the number of symbols. An empty DYNSYM |
| 15 | * table would work, but I see no reason not to write a valid one (and |
| 16 | * keep full performance for old Go programs). This hack is only |
| 17 | * needed on x86_64. |
| 18 | * |
| 19 | * The bug was introduced on 2012-08-31 by: |
| 20 | * https://code.google.com/p/go/source/detail?r=56ea40aac72b |
| 21 | * and was fixed on 2014-06-13 by: |
| 22 | * https://code.google.com/p/go/source/detail?r=fc1cd5e12595 |
| 23 | * |
| 24 | * Binutils has issues debugging the vDSO: it reads the section table to |
| 25 | * find SHT_NOTE; it won't look at PT_NOTE for the in-memory vDSO, which |
| 26 | * would break build-id if we removed the section table. Binutils |
| 27 | * also requires that shstrndx != 0. See: |
| 28 | * https://sourceware.org/bugzilla/show_bug.cgi?id=17064 |
| 29 | * |
| 30 | * elfutils might not look for PT_NOTE if there is a section table at |
| 31 | * all. I don't know whether this matters for any practical purpose. |
| 32 | * |
| 33 | * For simplicity, rather than hacking up a partial section table, we |
| 34 | * just write a mostly complete one. We omit non-dynamic symbols, |
| 35 | * though, since they're rather large. |
| 36 | * |
| 37 | * Once binutils gets fixed, we might be able to drop this for all but |
| 38 | * the 64-bit vdso, since build-id only works in kernel RPMs, and |
| 39 | * systems that update to new enough kernel RPMs will likely update |
| 40 | * binutils in sync. build-id has never worked for home-built kernel |
| 41 | * RPMs without manual symlinking, and I suspect that no one ever does |
| 42 | * that. |
| 43 | */ |
| 44 | struct BITSFUNC(fake_sections) |
| 45 | { |
| 46 | ELF(Shdr) *table; |
| 47 | unsigned long table_offset; |
| 48 | int count, max_count; |
| 49 | |
| 50 | int in_shstrndx; |
| 51 | unsigned long shstr_offset; |
| 52 | const char *shstrtab; |
| 53 | size_t shstrtab_len; |
| 54 | |
| 55 | int out_shstrndx; |
| 56 | }; |
| 57 | |
| 58 | static unsigned int BITSFUNC(find_shname)(struct BITSFUNC(fake_sections) *out, |
| 59 | const char *name) |
| 60 | { |
| 61 | const char *outname = out->shstrtab; |
| 62 | while (outname - out->shstrtab < out->shstrtab_len) { |
| 63 | if (!strcmp(name, outname)) |
| 64 | return (outname - out->shstrtab) + out->shstr_offset; |
| 65 | outname += strlen(outname) + 1; |
| 66 | } |
| 67 | |
| 68 | if (*name) |
| 69 | printf("Warning: could not find output name \"%s\"\n", name); |
| 70 | return out->shstr_offset + out->shstrtab_len - 1; /* Use a null. */ |
| 71 | } |
| 72 | |
| 73 | static void BITSFUNC(init_sections)(struct BITSFUNC(fake_sections) *out) |
| 74 | { |
| 75 | if (!out->in_shstrndx) |
| 76 | fail("didn't find the fake shstrndx\n"); |
| 77 | |
| 78 | memset(out->table, 0, out->max_count * sizeof(ELF(Shdr))); |
| 79 | |
| 80 | if (out->max_count < 1) |
| 81 | fail("we need at least two fake output sections\n"); |
| 82 | |
| 83 | PUT_LE(&out->table[0].sh_type, SHT_NULL); |
| 84 | PUT_LE(&out->table[0].sh_name, BITSFUNC(find_shname)(out, "")); |
| 85 | |
| 86 | out->count = 1; |
| 87 | } |
| 88 | |
| 89 | static void BITSFUNC(copy_section)(struct BITSFUNC(fake_sections) *out, |
| 90 | int in_idx, const ELF(Shdr) *in, |
| 91 | const char *name) |
| 92 | { |
| 93 | uint64_t flags = GET_LE(&in->sh_flags); |
| 94 | |
Andy Lutomirski | 0e3727a | 2014-06-18 15:59:49 -0700 | [diff] [blame] | 95 | bool copy = flags & SHF_ALLOC && |
| 96 | strcmp(name, ".altinstructions") && |
| 97 | strcmp(name, ".altinstr_replacement"); |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame] | 98 | |
| 99 | if (!copy) |
| 100 | return; |
| 101 | |
| 102 | if (out->count >= out->max_count) |
| 103 | fail("too many copied sections (max = %d)\n", out->max_count); |
| 104 | |
| 105 | if (in_idx == out->in_shstrndx) |
| 106 | out->out_shstrndx = out->count; |
| 107 | |
| 108 | out->table[out->count] = *in; |
| 109 | PUT_LE(&out->table[out->count].sh_name, |
| 110 | BITSFUNC(find_shname)(out, name)); |
| 111 | |
| 112 | /* elfutils requires that a strtab have the correct type. */ |
| 113 | if (!strcmp(name, ".fake_shstrtab")) |
| 114 | PUT_LE(&out->table[out->count].sh_type, SHT_STRTAB); |
| 115 | |
| 116 | out->count++; |
| 117 | } |
| 118 | |
Andy Lutomirski | c1979c3 | 2014-06-18 15:59:47 -0700 | [diff] [blame] | 119 | static void BITSFUNC(go)(void *addr, size_t len, |
| 120 | FILE *outfile, const char *name) |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 121 | { |
| 122 | int found_load = 0; |
| 123 | unsigned long load_size = -1; /* Work around bogus warning */ |
| 124 | unsigned long data_size; |
Andy Lutomirski | c1979c3 | 2014-06-18 15:59:47 -0700 | [diff] [blame] | 125 | ELF(Ehdr) *hdr = (ELF(Ehdr) *)addr; |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 126 | int i; |
| 127 | unsigned long j; |
Andy Lutomirski | c1979c3 | 2014-06-18 15:59:47 -0700 | [diff] [blame] | 128 | ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr, |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 129 | *alt_sec = NULL; |
Andy Lutomirski | c1979c3 | 2014-06-18 15:59:47 -0700 | [diff] [blame] | 130 | ELF(Dyn) *dyn = 0, *dyn_end = 0; |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 131 | const char *secstrings; |
| 132 | uint64_t syms[NSYMS] = {}; |
| 133 | |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame] | 134 | struct BITSFUNC(fake_sections) fake_sections = {}; |
Andy Lutomirski | e0bf7b8 | 2014-06-12 17:53:12 -0700 | [diff] [blame] | 135 | |
Andy Lutomirski | c1979c3 | 2014-06-18 15:59:47 -0700 | [diff] [blame] | 136 | ELF(Phdr) *pt = (ELF(Phdr) *)(addr + GET_LE(&hdr->e_phoff)); |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 137 | |
| 138 | /* Walk the segment table. */ |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 139 | for (i = 0; i < GET_LE(&hdr->e_phnum); i++) { |
| 140 | if (GET_LE(&pt[i].p_type) == PT_LOAD) { |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 141 | if (found_load) |
| 142 | fail("multiple PT_LOAD segs\n"); |
| 143 | |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 144 | if (GET_LE(&pt[i].p_offset) != 0 || |
| 145 | GET_LE(&pt[i].p_vaddr) != 0) |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 146 | fail("PT_LOAD in wrong place\n"); |
| 147 | |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 148 | if (GET_LE(&pt[i].p_memsz) != GET_LE(&pt[i].p_filesz)) |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 149 | fail("cannot handle memsz != filesz\n"); |
| 150 | |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 151 | load_size = GET_LE(&pt[i].p_memsz); |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 152 | found_load = 1; |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 153 | } else if (GET_LE(&pt[i].p_type) == PT_DYNAMIC) { |
| 154 | dyn = addr + GET_LE(&pt[i].p_offset); |
| 155 | dyn_end = addr + GET_LE(&pt[i].p_offset) + |
| 156 | GET_LE(&pt[i].p_memsz); |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 157 | } |
| 158 | } |
| 159 | if (!found_load) |
| 160 | fail("no PT_LOAD seg\n"); |
| 161 | data_size = (load_size + 4095) / 4096 * 4096; |
| 162 | |
| 163 | /* Walk the dynamic table */ |
H. Peter Anvin | c191920 | 2014-05-30 17:03:22 -0700 | [diff] [blame] | 164 | for (i = 0; dyn + i < dyn_end && |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 165 | GET_LE(&dyn[i].d_tag) != DT_NULL; i++) { |
| 166 | typeof(dyn[i].d_tag) tag = GET_LE(&dyn[i].d_tag); |
Andy Lutomirski | 6a89d71 | 2014-06-24 13:46:53 -0700 | [diff] [blame^] | 167 | if (tag == DT_REL || tag == DT_RELSZ || tag == DT_RELA || |
Andy Lutomirski | add4eed | 2014-05-30 08:48:49 -0700 | [diff] [blame] | 168 | tag == DT_RELENT || tag == DT_TEXTREL) |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 169 | fail("vdso image contains dynamic relocations\n"); |
| 170 | } |
| 171 | |
| 172 | /* Walk the section table */ |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 173 | secstrings_hdr = addr + GET_LE(&hdr->e_shoff) + |
| 174 | GET_LE(&hdr->e_shentsize)*GET_LE(&hdr->e_shstrndx); |
| 175 | secstrings = addr + GET_LE(&secstrings_hdr->sh_offset); |
| 176 | for (i = 0; i < GET_LE(&hdr->e_shnum); i++) { |
Andy Lutomirski | c1979c3 | 2014-06-18 15:59:47 -0700 | [diff] [blame] | 177 | ELF(Shdr) *sh = addr + GET_LE(&hdr->e_shoff) + |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 178 | GET_LE(&hdr->e_shentsize) * i; |
| 179 | if (GET_LE(&sh->sh_type) == SHT_SYMTAB) |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 180 | symtab_hdr = sh; |
| 181 | |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 182 | if (!strcmp(secstrings + GET_LE(&sh->sh_name), |
H. Peter Anvin | c191920 | 2014-05-30 17:03:22 -0700 | [diff] [blame] | 183 | ".altinstructions")) |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 184 | alt_sec = sh; |
| 185 | } |
| 186 | |
Andy Lutomirski | 0115618 | 2014-05-30 08:48:48 -0700 | [diff] [blame] | 187 | if (!symtab_hdr) |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 188 | fail("no symbol table\n"); |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 189 | |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 190 | strtab_hdr = addr + GET_LE(&hdr->e_shoff) + |
| 191 | GET_LE(&hdr->e_shentsize) * GET_LE(&symtab_hdr->sh_link); |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 192 | |
| 193 | /* Walk the symbol table */ |
H. Peter Anvin | c191920 | 2014-05-30 17:03:22 -0700 | [diff] [blame] | 194 | for (i = 0; |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 195 | i < GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize); |
Andy Lutomirski | add4eed | 2014-05-30 08:48:49 -0700 | [diff] [blame] | 196 | i++) { |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 197 | int k; |
Andy Lutomirski | c1979c3 | 2014-06-18 15:59:47 -0700 | [diff] [blame] | 198 | ELF(Sym) *sym = addr + GET_LE(&symtab_hdr->sh_offset) + |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 199 | GET_LE(&symtab_hdr->sh_entsize) * i; |
| 200 | const char *name = addr + GET_LE(&strtab_hdr->sh_offset) + |
| 201 | GET_LE(&sym->st_name); |
Andy Lutomirski | e0bf7b8 | 2014-06-12 17:53:12 -0700 | [diff] [blame] | 202 | |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 203 | for (k = 0; k < NSYMS; k++) { |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame] | 204 | if (!strcmp(name, required_syms[k].name)) { |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 205 | if (syms[k]) { |
| 206 | fail("duplicate symbol %s\n", |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame] | 207 | required_syms[k].name); |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 208 | } |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 209 | syms[k] = GET_LE(&sym->st_value); |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 210 | } |
| 211 | } |
Andy Lutomirski | e0bf7b8 | 2014-06-12 17:53:12 -0700 | [diff] [blame] | 212 | |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame] | 213 | if (!strcmp(name, "fake_shstrtab")) { |
| 214 | ELF(Shdr) *sh; |
| 215 | |
| 216 | fake_sections.in_shstrndx = GET_LE(&sym->st_shndx); |
| 217 | fake_sections.shstrtab = addr + GET_LE(&sym->st_value); |
| 218 | fake_sections.shstrtab_len = GET_LE(&sym->st_size); |
| 219 | sh = addr + GET_LE(&hdr->e_shoff) + |
| 220 | GET_LE(&hdr->e_shentsize) * |
| 221 | fake_sections.in_shstrndx; |
| 222 | fake_sections.shstr_offset = GET_LE(&sym->st_value) - |
| 223 | GET_LE(&sh->sh_addr); |
Andy Lutomirski | e0bf7b8 | 2014-06-12 17:53:12 -0700 | [diff] [blame] | 224 | } |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 225 | } |
| 226 | |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame] | 227 | /* Build the output section table. */ |
| 228 | if (!syms[sym_VDSO_FAKE_SECTION_TABLE_START] || |
| 229 | !syms[sym_VDSO_FAKE_SECTION_TABLE_END]) |
| 230 | fail("couldn't find fake section table\n"); |
| 231 | if ((syms[sym_VDSO_FAKE_SECTION_TABLE_END] - |
| 232 | syms[sym_VDSO_FAKE_SECTION_TABLE_START]) % sizeof(ELF(Shdr))) |
| 233 | fail("fake section table size isn't a multiple of sizeof(Shdr)\n"); |
| 234 | fake_sections.table = addr + syms[sym_VDSO_FAKE_SECTION_TABLE_START]; |
| 235 | fake_sections.table_offset = syms[sym_VDSO_FAKE_SECTION_TABLE_START]; |
| 236 | fake_sections.max_count = (syms[sym_VDSO_FAKE_SECTION_TABLE_END] - |
| 237 | syms[sym_VDSO_FAKE_SECTION_TABLE_START]) / |
| 238 | sizeof(ELF(Shdr)); |
| 239 | |
| 240 | BITSFUNC(init_sections)(&fake_sections); |
| 241 | for (i = 0; i < GET_LE(&hdr->e_shnum); i++) { |
| 242 | ELF(Shdr) *sh = addr + GET_LE(&hdr->e_shoff) + |
| 243 | GET_LE(&hdr->e_shentsize) * i; |
| 244 | BITSFUNC(copy_section)(&fake_sections, i, sh, |
| 245 | secstrings + GET_LE(&sh->sh_name)); |
| 246 | } |
| 247 | if (!fake_sections.out_shstrndx) |
| 248 | fail("didn't generate shstrndx?!?\n"); |
| 249 | |
| 250 | PUT_LE(&hdr->e_shoff, fake_sections.table_offset); |
| 251 | PUT_LE(&hdr->e_shentsize, sizeof(ELF(Shdr))); |
| 252 | PUT_LE(&hdr->e_shnum, fake_sections.count); |
| 253 | PUT_LE(&hdr->e_shstrndx, fake_sections.out_shstrndx); |
| 254 | |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 255 | /* Validate mapping addresses. */ |
| 256 | for (i = 0; i < sizeof(special_pages) / sizeof(special_pages[0]); i++) { |
| 257 | if (!syms[i]) |
| 258 | continue; /* The mapping isn't used; ignore it. */ |
| 259 | |
| 260 | if (syms[i] % 4096) |
| 261 | fail("%s must be a multiple of 4096\n", |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame] | 262 | required_syms[i].name); |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 263 | if (syms[i] < data_size) |
| 264 | fail("%s must be after the text mapping\n", |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame] | 265 | required_syms[i].name); |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 266 | if (syms[sym_end_mapping] < syms[i] + 4096) |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame] | 267 | fail("%s overruns end_mapping\n", |
| 268 | required_syms[i].name); |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 269 | } |
| 270 | if (syms[sym_end_mapping] % 4096) |
| 271 | fail("end_mapping must be a multiple of 4096\n"); |
| 272 | |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 273 | if (!name) { |
| 274 | fwrite(addr, load_size, 1, outfile); |
Andy Lutomirski | 0115618 | 2014-05-30 08:48:48 -0700 | [diff] [blame] | 275 | return; |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | fprintf(outfile, "/* AUTOMATICALLY GENERATED -- DO NOT EDIT */\n\n"); |
| 279 | fprintf(outfile, "#include <linux/linkage.h>\n"); |
| 280 | fprintf(outfile, "#include <asm/page_types.h>\n"); |
| 281 | fprintf(outfile, "#include <asm/vdso.h>\n"); |
| 282 | fprintf(outfile, "\n"); |
| 283 | fprintf(outfile, |
| 284 | "static unsigned char raw_data[%lu] __page_aligned_data = {", |
| 285 | data_size); |
| 286 | for (j = 0; j < load_size; j++) { |
| 287 | if (j % 10 == 0) |
| 288 | fprintf(outfile, "\n\t"); |
| 289 | fprintf(outfile, "0x%02X, ", (int)((unsigned char *)addr)[j]); |
| 290 | } |
| 291 | fprintf(outfile, "\n};\n\n"); |
| 292 | |
| 293 | fprintf(outfile, "static struct page *pages[%lu];\n\n", |
| 294 | data_size / 4096); |
| 295 | |
| 296 | fprintf(outfile, "const struct vdso_image %s = {\n", name); |
| 297 | fprintf(outfile, "\t.data = raw_data,\n"); |
| 298 | fprintf(outfile, "\t.size = %lu,\n", data_size); |
Andy Lutomirski | a62c34b | 2014-05-19 15:58:33 -0700 | [diff] [blame] | 299 | fprintf(outfile, "\t.text_mapping = {\n"); |
| 300 | fprintf(outfile, "\t\t.name = \"[vdso]\",\n"); |
| 301 | fprintf(outfile, "\t\t.pages = pages,\n"); |
| 302 | fprintf(outfile, "\t},\n"); |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 303 | if (alt_sec) { |
| 304 | fprintf(outfile, "\t.alt = %lu,\n", |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 305 | (unsigned long)GET_LE(&alt_sec->sh_offset)); |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 306 | fprintf(outfile, "\t.alt_len = %lu,\n", |
H. Peter Anvin | bdfb9bc | 2014-06-06 14:30:37 -0700 | [diff] [blame] | 307 | (unsigned long)GET_LE(&alt_sec->sh_size)); |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 308 | } |
| 309 | for (i = 0; i < NSYMS; i++) { |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame] | 310 | if (required_syms[i].export && syms[i]) |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 311 | fprintf(outfile, "\t.sym_%s = 0x%" PRIx64 ",\n", |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame] | 312 | required_syms[i].name, syms[i]); |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 313 | } |
| 314 | fprintf(outfile, "};\n"); |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 315 | } |