Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(964)

Side by Side Diff: nacl/dyn-link/ldscripts/elf64_nacl.xs

Issue 13638011: Align and pad code segments to 64k (Closed) Base URL: http://git.chromium.org/native_client/nacl-glibc.git@master
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « nacl/dyn-link/ldscripts/elf64_nacl.x ('k') | nacl/dyn-link/ldscripts/elf_nacl.x » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Script for ld --shared: link shared library */ 1 /* Script for ld --shared: link shared library */
2 OUTPUT_FORMAT("elf64-nacl", "elf64-nacl", 2 OUTPUT_FORMAT("elf64-nacl", "elf64-nacl",
3 "elf64-nacl") 3 "elf64-nacl")
4 OUTPUT_ARCH(i386:x86-64) 4 OUTPUT_ARCH(i386:x86-64)
5 ENTRY(_start) 5 ENTRY(_start)
6 SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); 6 SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
7 PHDRS 7 PHDRS
8 { 8 {
9 seg_code PT_LOAD FLAGS(5) ; /* read + execute */ 9 seg_code PT_LOAD FLAGS(5) ; /* read + execute */
10 seg_rodata PT_LOAD FLAGS(4) ; /* read */ 10 seg_rodata PT_LOAD FLAGS(4) ; /* read */
11 seg_rwdata PT_LOAD FLAGS(6) ; /* read + write */ 11 seg_rwdata PT_LOAD FLAGS(6) ; /* read + write */
12 seg_bss PT_LOAD FLAGS(6) ; /* read + write */ 12 seg_bss PT_LOAD FLAGS(6) ; /* read + write */
13 seg_dynamic PT_DYNAMIC FLAGS(6) ; 13 seg_dynamic PT_DYNAMIC FLAGS(6) ;
14 seg_stack PT_GNU_STACK FLAGS(6) ; 14 seg_stack PT_GNU_STACK FLAGS(6) ;
15 seg_tls PT_TLS FLAGS(4) ; 15 seg_tls PT_TLS FLAGS(4) ;
16 } 16 }
17 SECTIONS 17 SECTIONS
18 { 18 {
19 /* NaCl runtime treats ld.so as an executable. NaCl executables must have 19 . = SEGMENT_START("text", 0);
20 page-aligned code and data segments, so linker script for ld.so is patched
21 to remove SIZEOF_HEADERS below and make code segment aligned to page
22 boundary. */
23 . = SEGMENT_START("text", 0) + SIZEOF_HEADERS;
24 _begin = .; 20 _begin = .;
21
25 /* The ALIGN(32) instructions below are workarounds. 22 /* The ALIGN(32) instructions below are workarounds.
26 TODO(mseaborn): Get the object files to include the correct 23 TODO(mseaborn): Get the object files to include the correct
27 alignments and padding themselves. 24 alignments and padding themselves.
28 See http://code.google.com/p/nativeclient/issues/detail?id=499. */ 25 See http://code.google.com/p/nativeclient/issues/detail?id=499. */
29 .init : SUBALIGN(32) 26 .init : SUBALIGN(32)
30 { 27 {
31 KEEP (*(.init)) 28 KEEP (*(.init))
32 . = ALIGN(32); /* ensure nop padding */ 29 . = ALIGN(32); /* ensure nop padding */
33 } :seg_code =0x90909090 30 } :seg_code =0x90909090
34 .plt : { *(.plt) } 31 .plt : { *(.plt) }
35 .text : SUBALIGN(32) 32 .text : SUBALIGN(32)
36 { 33 {
37 *(.text .stub .text.* .gnu.linkonce.t.*) 34 *(.text .stub .text.* .gnu.linkonce.t.*)
38 KEEP (*(.text.*personality*)) 35 KEEP (*(.text.*personality*))
39 /* .gnu.warning sections are handled specially by elf32.em. */ 36 /* .gnu.warning sections are handled specially by elf32.em. */
40 *(.gnu.warning) 37 *(.gnu.warning)
41 /* Putting .fini here makes the align pad correctly when .fini is empty. 38 /* Putting .fini here makes the align pad correctly when .fini is empty.
42 Listing the __libc* sections is also necessary to make padding work. */ 39 Listing the __libc* sections is also necessary to make padding work. */
43 KEEP (*(.fini)) 40 KEEP (*(.fini))
44 *(__libc_freeres_fn) 41 *(__libc_freeres_fn)
45 *(__libc_thread_freeres_fn) 42 *(__libc_thread_freeres_fn)
46 . = ALIGN(32); /* ensure nop padding */ 43 . = ALIGN(CONSTANT (MAXPAGESIZE)); /* ensures NOP fill */
47 } =0x90909090 44 } =0x90909090
48 PROVIDE (__etext = .); 45 PROVIDE (__etext = .);
49 PROVIDE (_etext = .); 46 PROVIDE (_etext = .);
50 PROVIDE (etext = .); 47 PROVIDE (etext = .);
51 48
52 /* Adjust data segment so that is has the same position within the page as 49 . = ALIGN(SEGMENT_START("text", 0) + 0x10000000, CONSTANT (MAXPAGESIZE));
53 the end of code segment. In this case linker can store them without any
54 zeros in between.
55
56 NaCl runtime treats ld.so as an executable which must have page-aligned
57 read-only data segment. So the last term is replaced with 0 while patching
58 linker script for ld.so. */
59 . = SEGMENT_START("text", 0) + 0x10000000 +
60 (. & (CONSTANT (MAXPAGESIZE) - 1));
61 .note.gnu.build-id : { *(.note.gnu.build-id) } :seg_rodata 50 .note.gnu.build-id : { *(.note.gnu.build-id) } :seg_rodata
62 .hash : { *(.hash) } 51 .hash : { *(.hash) }
63 .gnu.hash : { *(.gnu.hash) } 52 .gnu.hash : { *(.gnu.hash) }
64 .dynsym : { *(.dynsym) } 53 .dynsym : { *(.dynsym) }
65 .dynstr : { *(.dynstr) } 54 .dynstr : { *(.dynstr) }
66 .gnu.version : { *(.gnu.version) } 55 .gnu.version : { *(.gnu.version) }
67 .gnu.version_d : { *(.gnu.version_d) } 56 .gnu.version_d : { *(.gnu.version_d) }
68 .gnu.version_r : { *(.gnu.version_r) } 57 .gnu.version_r : { *(.gnu.version_r) }
69 .rel.init : { *(.rel.init) } 58 .rel.init : { *(.rel.init) }
70 .rela.init : { *(.rela.init) } 59 .rela.init : { *(.rela.init) }
(...skipping 24 matching lines...) Expand all
95 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } 84 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
96 .rodata1 : { *(.rodata1) } 85 .rodata1 : { *(.rodata1) }
97 .eh_frame_hdr : { *(.eh_frame_hdr) } 86 .eh_frame_hdr : { *(.eh_frame_hdr) }
98 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } 87 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
99 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } 88 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
100 /* Adjust the address for the data segment. We want to adjust up to 89 /* Adjust the address for the data segment. We want to adjust up to
101 the same address within the page on the next page up. */ 90 the same address within the page on the next page up. */
102 . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT ( COMMONPAGESIZE)); 91 . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT ( COMMONPAGESIZE));
103 /* Executables loaded by sel_ldr are not required to have seg_rwdata aligned 92 /* Executables loaded by sel_ldr are not required to have seg_rwdata aligned
104 to page boundary. So we can omit alignment here both for ld.so and normal 93 to page boundary. So we can omit alignment here both for ld.so and normal
105 libraries. */ 94 libraries. */
106 /* Exception handling */ 95 /* Exception handling */
107 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } :seg_rwdata 96 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } :seg_rwdata
108 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } 97 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
109 /* Thread Local Storage sections */ 98 /* Thread Local Storage sections */
110 .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } :seg_rwdata :seg_t ls 99 .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } :seg_rwdata :seg_t ls
111 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } 100 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
112 .preinit_array : 101 .preinit_array :
113 { 102 {
114 KEEP (*(.preinit_array)) 103 KEEP (*(.preinit_array))
115 } :seg_rwdata 104 } :seg_rwdata
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 .debug_funcnames 0 : { *(.debug_funcnames) } 224 .debug_funcnames 0 : { *(.debug_funcnames) }
236 .debug_typenames 0 : { *(.debug_typenames) } 225 .debug_typenames 0 : { *(.debug_typenames) }
237 .debug_varnames 0 : { *(.debug_varnames) } 226 .debug_varnames 0 : { *(.debug_varnames) }
238 /* DWARF 3 */ 227 /* DWARF 3 */
239 .debug_pubtypes 0 : { *(.debug_pubtypes) } 228 .debug_pubtypes 0 : { *(.debug_pubtypes) }
240 .debug_ranges 0 : { *(.debug_ranges) } 229 .debug_ranges 0 : { *(.debug_ranges) }
241 .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } 230 .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
242 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) } 231 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }
243 /DISCARD/ : { *(.note.ABI-tag) } 232 /DISCARD/ : { *(.note.ABI-tag) }
244 } 233 }
OLDNEW
« no previous file with comments | « nacl/dyn-link/ldscripts/elf64_nacl.x ('k') | nacl/dyn-link/ldscripts/elf_nacl.x » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698