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

Side by Side Diff: nacl/dyn-link/ldscripts/elf_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/elf_nacl.x ('k') | no next file » | 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("elf32-nacl", "elf32-nacl", 2 OUTPUT_FORMAT("elf32-nacl", "elf32-nacl",
3 "elf32-nacl") 3 "elf32-nacl")
4 OUTPUT_ARCH(i386) 4 OUTPUT_ARCH(i386)
5 ENTRY(_start) 5 ENTRY(_start)
6 SEARCH_DIR("=/usr/local/lib32"); SEARCH_DIR("=/lib32"); SEARCH_DIR("=/usr/lib32" ); 6 SEARCH_DIR("=/usr/local/lib32"); SEARCH_DIR("=/lib32"); SEARCH_DIR("=/usr/lib32" );
7 SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); 7 SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
8 PHDRS 8 PHDRS
9 { 9 {
10 seg_code PT_LOAD FLAGS(5) ; /* read + execute */ 10 seg_code PT_LOAD FLAGS(5) ; /* read + execute */
11 seg_rodata PT_LOAD FLAGS(4) ; /* read */ 11 seg_rodata PT_LOAD FLAGS(4) ; /* read */
12 seg_rwdata PT_LOAD FLAGS(6) ; /* read + write */ 12 seg_rwdata PT_LOAD FLAGS(6) ; /* read + write */
13 seg_bss PT_LOAD FLAGS(6) ; /* read + write */ 13 seg_bss PT_LOAD FLAGS(6) ; /* read + write */
14 seg_dynamic PT_DYNAMIC FLAGS(6) ; 14 seg_dynamic PT_DYNAMIC FLAGS(6) ;
15 seg_stack PT_GNU_STACK FLAGS(6) ; 15 seg_stack PT_GNU_STACK FLAGS(6) ;
16 seg_tls PT_TLS FLAGS(4) ; 16 seg_tls PT_TLS FLAGS(4) ;
17 } 17 }
18 SECTIONS 18 SECTIONS
19 { 19 {
20 /* NaCl runtime treats ld.so as an executable. NaCl executables must have 20 . = SEGMENT_START("text", 0);
21 page-aligned code and data segments, so linker script for ld.so is patched
22 to remove SIZEOF_HEADERS below and make code segment aligned to page
23 boundary. */
24 . = SEGMENT_START("text", 0) + SIZEOF_HEADERS;
25 _begin = .; 21 _begin = .;
22
26 /* The ALIGN(32) instructions below are workarounds. 23 /* The ALIGN(32) instructions below are workarounds.
27 TODO(mseaborn): Get the object files to include the correct 24 TODO(mseaborn): Get the object files to include the correct
28 alignments and padding themselves. 25 alignments and padding themselves.
29 See http://code.google.com/p/nativeclient/issues/detail?id=499. */ 26 See http://code.google.com/p/nativeclient/issues/detail?id=499. */
30 .init : SUBALIGN(32) 27 .init : SUBALIGN(32)
31 { 28 {
32 KEEP (*(.init)) 29 KEEP (*(.init))
33 . = ALIGN(32); /* ensure nop padding */ 30 . = ALIGN(32); /* ensure nop padding */
34 } :seg_code =0x90909090 31 } :seg_code =0x90909090
35 .plt : { *(.plt) } 32 .plt : { *(.plt) }
36 .text : SUBALIGN(32) 33 .text : SUBALIGN(32)
37 { 34 {
38 *(.text .stub .text.* .gnu.linkonce.t.*) 35 *(.text .stub .text.* .gnu.linkonce.t.*)
39 KEEP (*(.text.*personality*)) 36 KEEP (*(.text.*personality*))
40 /* .gnu.warning sections are handled specially by elf32.em. */ 37 /* .gnu.warning sections are handled specially by elf32.em. */
41 *(.gnu.warning) 38 *(.gnu.warning)
42 /* Putting .fini here makes the align pad correctly when .fini is empty. 39 /* Putting .fini here makes the align pad correctly when .fini is empty.
43 Listing the __libc* sections is also necessary to make padding work. */ 40 Listing the __libc* sections is also necessary to make padding work. */
44 KEEP (*(.fini)) 41 KEEP (*(.fini))
45 *(__libc_freeres_fn) 42 *(__libc_freeres_fn)
46 *(__libc_thread_freeres_fn) 43 *(__libc_thread_freeres_fn)
47 . = ALIGN(32); /* ensure nop padding */ 44 . = ALIGN(CONSTANT (MAXPAGESIZE)); /* ensures NOP fill */
48 } =0x90909090 45 } =0x90909090
49 PROVIDE (__etext = .); 46 PROVIDE (__etext = .);
50 PROVIDE (_etext = .); 47 PROVIDE (_etext = .);
51 PROVIDE (etext = .); 48 PROVIDE (etext = .);
52 49
53 /* Adjust data segment so that is has the same position within the page as 50 . = ALIGN(SEGMENT_START("text", 0) + 0x10000000, CONSTANT (MAXPAGESIZE));
54 the end of code segment. In this case linker can store them without any
55 zeros in between.
56
57 NaCl runtime treats ld.so as an executable which must have page-aligned
58 read-only data segment. So the last term is replaced with 0 while patching
59 linker script for ld.so. */
60 . = SEGMENT_START("text", 0) + 0x10000000 +
61 (. & (CONSTANT (MAXPAGESIZE) - 1));
62 .note.gnu.build-id : { *(.note.gnu.build-id) } :seg_rodata 51 .note.gnu.build-id : { *(.note.gnu.build-id) } :seg_rodata
63 .hash : { *(.hash) } 52 .hash : { *(.hash) }
64 .gnu.hash : { *(.gnu.hash) } 53 .gnu.hash : { *(.gnu.hash) }
65 .dynsym : { *(.dynsym) } 54 .dynsym : { *(.dynsym) }
66 .dynstr : { *(.dynstr) } 55 .dynstr : { *(.dynstr) }
67 .gnu.version : { *(.gnu.version) } 56 .gnu.version : { *(.gnu.version) }
68 .gnu.version_d : { *(.gnu.version_d) } 57 .gnu.version_d : { *(.gnu.version_d) }
69 .gnu.version_r : { *(.gnu.version_r) } 58 .gnu.version_r : { *(.gnu.version_r) }
70 .rel.init : { *(.rel.init) } 59 .rel.init : { *(.rel.init) }
71 .rela.init : { *(.rela.init) } 60 .rela.init : { *(.rela.init) }
(...skipping 17 matching lines...) Expand all
89 .rela.dtors : { *(.rela.dtors) } 78 .rela.dtors : { *(.rela.dtors) }
90 .rel.got : { *(.rel.got) } 79 .rel.got : { *(.rel.got) }
91 .rela.got : { *(.rela.got) } 80 .rela.got : { *(.rela.got) }
92 .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } 81 .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
93 .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } 82 .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
94 .rel.plt : { *(.rel.plt) } 83 .rel.plt : { *(.rel.plt) }
95 .rela.plt : { *(.rela.plt) } 84 .rela.plt : { *(.rela.plt) }
96 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } 85 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
97 .rodata1 : { *(.rodata1) } 86 .rodata1 : { *(.rodata1) }
98 .eh_frame_hdr : { *(.eh_frame_hdr) } 87 .eh_frame_hdr : { *(.eh_frame_hdr) }
99 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } 88 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
100 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } 89 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
101 /* Adjust the address for the data segment. We want to adjust up to 90 /* Adjust the address for the data segment. We want to adjust up to
102 the same address within the page on the next page up. */ 91 the same address within the page on the next page up. */
103 . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT ( COMMONPAGESIZE)); 92 . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT ( COMMONPAGESIZE));
104 /* Executables loaded by sel_ldr are not required to have seg_rwdata aligned 93 /* Executables loaded by sel_ldr are not required to have seg_rwdata aligned
105 to page boundary. So we can omit alignment here both for ld.so and normal 94 to page boundary. So we can omit alignment here both for ld.so and normal
106 libraries. */ 95 libraries. */
107 /* Exception handling */ 96 /* Exception handling */
108 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } :seg_rwdata 97 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } :seg_rwdata
109 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } 98 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 .debug_funcnames 0 : { *(.debug_funcnames) } 225 .debug_funcnames 0 : { *(.debug_funcnames) }
237 .debug_typenames 0 : { *(.debug_typenames) } 226 .debug_typenames 0 : { *(.debug_typenames) }
238 .debug_varnames 0 : { *(.debug_varnames) } 227 .debug_varnames 0 : { *(.debug_varnames) }
239 /* DWARF 3 */ 228 /* DWARF 3 */
240 .debug_pubtypes 0 : { *(.debug_pubtypes) } 229 .debug_pubtypes 0 : { *(.debug_pubtypes) }
241 .debug_ranges 0 : { *(.debug_ranges) } 230 .debug_ranges 0 : { *(.debug_ranges) }
242 .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } 231 .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
243 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) } 232 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }
244 /DISCARD/ : { *(.note.ABI-tag) } 233 /DISCARD/ : { *(.note.ABI-tag) }
245 } 234 }
OLDNEW
« no previous file with comments | « nacl/dyn-link/ldscripts/elf_nacl.x ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698