3 # Define linkage sections required by GUPC by editing
4 # the default GNU ld script.
7 my $before_ctors = <<EOD;
10 PROVIDE (__upc_alloc_array_start = .);
11 KEEP (*(SORT(upc_alloc_array.*)))
12 KEEP (*(upc_alloc_array))
13 PROVIDE (__upc_alloc_array_end = .);
15 .upc_alloc : { KEEP(*(upc_alloc)) }
18 PROVIDE (__upc_init_array_start = .);
19 KEEP (*(SORT(upc_init_array.*)))
20 KEEP (*(upc_init_array))
21 PROVIDE (__upc_init_array_end = .);
23 .upc_init : { KEEP(*(upc_init)) }
24 /* UPC Program Info - compilation-related data */
27 PROVIDE (__upc_pgm_info_start = .);
28 KEEP (*(upc_pgm_info));
29 PROVIDE (__upc_pgm_info_end = .);
32 my $after_end_dot = <<EOD;
33 /* UPC shared section - used to layout shared data only */
34 .upc_shared 0x4000 (NOLOAD):
36 PROVIDE (__upc_shared_start = .);
38 PROVIDE (__upc_shared_end = .);
41 my $ld_script = do {local $/ = undef; <>};
44 m{^GNU ld} or die "Not a GNU ld script?";
45 my $is_ia64 = /OUTPUT_ARCH\s*\(\s*ia64\s*\)/s;
48 # The linker on the IA64 (SuSE) can't handle the
49 # additional "nolaod" attribute. Drop it.
50 $after_end_dot =~ s/\s*\(NOLOAD\)//s;
53 s/\n(?:\s*\n)*=+\n.*$/\n/s;
54 s/^(.*\n)(\s*\.ctors.*?\n)/$1$before_ctors$2/s
55 or die "No match on .ctors line";
56 m{(\n\s*\.\s*\=\s*ALIGN\s*\(\s*\d+\s*/\s*8\s*\)\s*;[^\n]*\n)}s;
57 my $align = defined($1) ?
"$1" : '';
58 s
{\n((?
:\s
*\
.\s
*\
=\s
*ALIGN\s
*\
(\s
*\d
+\s
*/\s
*\d
+\s
*\
)\s
*;[^\n]*\n)*?
60 \s
*PROVIDE\s
*\
(\s
*end\s
*=\s
*\
.\s
*\
)\s
*;[^\n]*\n
61 (?
:\s
*\
.\s
*\
=\s
*DATA_SEGMENT_END\s
*\
(\s
*\
.\s
*\
)\s
*;[^\n]*\n)?
)}
63 or die "No match on '_end = .;' line";