Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 1 | #include <asm/vdso.h> |
| 2 | |
Roland McGrath | f6b46eb | 2008-01-30 13:30:41 +0100 | [diff] [blame] | 3 | /* |
| 4 | * Linker script for vDSO. This is an ELF shared object prelinked to |
| 5 | * its virtual address, and with only one read-only segment. |
| 6 | * This script controls its layout. |
| 7 | */ |
| 8 | |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame^] | 9 | #if defined(BUILD_VDSO64) |
| 10 | # define SHDR_SIZE 64 |
| 11 | #elif defined(BUILD_VDSO32) || defined(BUILD_VDSOX32) |
| 12 | # define SHDR_SIZE 40 |
| 13 | #else |
| 14 | # error unknown VDSO target |
| 15 | #endif |
| 16 | |
| 17 | #define NUM_FAKE_SHDRS 16 |
| 18 | |
Roland McGrath | f6b46eb | 2008-01-30 13:30:41 +0100 | [diff] [blame] | 19 | SECTIONS |
| 20 | { |
Andy Lutomirski | b0b49f2 | 2014-03-13 16:01:26 -0700 | [diff] [blame] | 21 | . = SIZEOF_HEADERS; |
Roland McGrath | f6b46eb | 2008-01-30 13:30:41 +0100 | [diff] [blame] | 22 | |
| 23 | .hash : { *(.hash) } :text |
| 24 | .gnu.hash : { *(.gnu.hash) } |
| 25 | .dynsym : { *(.dynsym) } |
| 26 | .dynstr : { *(.dynstr) } |
| 27 | .gnu.version : { *(.gnu.version) } |
| 28 | .gnu.version_d : { *(.gnu.version_d) } |
| 29 | .gnu.version_r : { *(.gnu.version_r) } |
| 30 | |
| 31 | .note : { *(.note.*) } :text :note |
| 32 | |
| 33 | .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr |
| 34 | .eh_frame : { KEEP (*(.eh_frame)) } :text |
| 35 | |
| 36 | .dynamic : { *(.dynamic) } :text :dynamic |
| 37 | |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame^] | 38 | .rodata : { |
| 39 | *(.rodata*) |
| 40 | |
| 41 | /* |
| 42 | * Ideally this would live in a C file, but that won't |
| 43 | * work cleanly for x32 until we start building the x32 |
| 44 | * C code using an x32 toolchain. |
| 45 | */ |
| 46 | VDSO_FAKE_SECTION_TABLE_START = .; |
| 47 | . = . + NUM_FAKE_SHDRS * SHDR_SIZE; |
| 48 | VDSO_FAKE_SECTION_TABLE_END = .; |
| 49 | } :text |
| 50 | |
| 51 | .fake_shstrtab : { *(.fake_shstrtab) } :text |
| 52 | |
Roland McGrath | f6b46eb | 2008-01-30 13:30:41 +0100 | [diff] [blame] | 53 | .data : { |
Andy Lutomirski | bfad381 | 2014-06-18 15:59:48 -0700 | [diff] [blame^] | 54 | *(.data*) |
| 55 | *(.sdata*) |
| 56 | *(.got.plt) *(.got) |
| 57 | *(.gnu.linkonce.d.*) |
| 58 | *(.bss*) |
| 59 | *(.dynbss*) |
| 60 | *(.gnu.linkonce.b.*) |
Roland McGrath | f6b46eb | 2008-01-30 13:30:41 +0100 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | .altinstructions : { *(.altinstructions) } |
| 64 | .altinstr_replacement : { *(.altinstr_replacement) } |
| 65 | |
| 66 | /* |
| 67 | * Align the actual code well away from the non-instruction data. |
| 68 | * This is the best thing for the I-cache. |
| 69 | */ |
| 70 | . = ALIGN(0x100); |
| 71 | |
Andy Lutomirski | 378ed3c | 2014-04-03 10:53:43 -0700 | [diff] [blame] | 72 | .text : { *(.text*) } :text =0x90909090, |
| 73 | |
| 74 | /* |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 75 | * The remainder of the vDSO consists of special pages that are |
| 76 | * shared between the kernel and userspace. It needs to be at the |
| 77 | * end so that it doesn't overlap the mapping of the actual |
| 78 | * vDSO image. |
Andy Lutomirski | 378ed3c | 2014-04-03 10:53:43 -0700 | [diff] [blame] | 79 | */ |
H. Peter Anvin | 26f5ef2 | 2014-03-25 13:41:36 -0700 | [diff] [blame] | 80 | |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 81 | . = ALIGN(PAGE_SIZE); |
| 82 | vvar_page = .; |
| 83 | |
| 84 | /* Place all vvars at the offsets in asm/vvar.h. */ |
| 85 | #define EMIT_VVAR(name, offset) vvar_ ## name = vvar_page + offset; |
| 86 | #define __VVAR_KERNEL_LDS |
| 87 | #include <asm/vvar.h> |
| 88 | #undef __VVAR_KERNEL_LDS |
| 89 | #undef EMIT_VVAR |
| 90 | |
| 91 | . = vvar_page + PAGE_SIZE; |
| 92 | |
| 93 | hpet_page = .; |
| 94 | . = . + PAGE_SIZE; |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 95 | |
| 96 | . = ALIGN(PAGE_SIZE); |
| 97 | end_mapping = .; |
| 98 | |
H. Peter Anvin | 26f5ef2 | 2014-03-25 13:41:36 -0700 | [diff] [blame] | 99 | /DISCARD/ : { |
| 100 | *(.discard) |
| 101 | *(.discard.*) |
Andy Lutomirski | 5f56e71 | 2014-06-18 15:59:46 -0700 | [diff] [blame] | 102 | *(__bug_table) |
H. Peter Anvin | 26f5ef2 | 2014-03-25 13:41:36 -0700 | [diff] [blame] | 103 | } |
Roland McGrath | f6b46eb | 2008-01-30 13:30:41 +0100 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | /* |
| 107 | * Very old versions of ld do not recognize this name token; use the constant. |
| 108 | */ |
| 109 | #define PT_GNU_EH_FRAME 0x6474e550 |
| 110 | |
| 111 | /* |
| 112 | * We must supply the ELF program headers explicitly to get just one |
| 113 | * PT_LOAD segment, and set the flags explicitly to make segments read-only. |
| 114 | */ |
| 115 | PHDRS |
| 116 | { |
| 117 | text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */ |
| 118 | dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ |
| 119 | note PT_NOTE FLAGS(4); /* PF_R */ |
| 120 | eh_frame_hdr PT_GNU_EH_FRAME; |
Roland McGrath | f6b46eb | 2008-01-30 13:30:41 +0100 | [diff] [blame] | 121 | } |