1 /* { dg-do compile } */
2 /* { dg-require-effective-target pie } */
3 /* { dg-options "-O2 -fpic" } */
4 
5 /* Weak initialized symbol with -fpic.  */
6 __attribute__((weak))
7 int xxx = -1;
8 
9 int
foo()10 foo ()
11 {
12   return xxx;
13 }
14 
15 /* { dg-final { scan-assembler-not "movl\[ \t\]xxx\\(%rip\\), %" { target { ! ia32 } } } } */
16 /* Darwin is always PIC so no change, weak symbols needs to be indirect and this
17    happens to match the ELF case.  */
18 /* { dg-final { scan-assembler "_?xxx@GOTPCREL" { target { ! ia32 } } } } */
19 
20 /* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %" { target { ia32 && { ! *-*-darwin* } } } } } */
21 /* { dg-final { scan-assembler "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %" { target { ia32 && { ! *-*-darwin* } } } } } */
22 
23 /* Darwin m32 default to PIC but needs indirection for the weak symbol.  */
24 /* { dg-final { scan-assembler {movl[ \t][Ll]_xxx\$non_lazy_ptr-L1\$pb\(%eax\),[ \t]%eax} { target { ia32 && *-*-darwin* } } } } */
25