1 /* PR 41750 - IPA-SRA used to pass hash->sgot by value rather than by
2    reference.  */
3 
4 struct bfd_link_hash_table
5 {
6   int hash;
7 };
8 
9 struct foo_link_hash_table
10 {
11   struct bfd_link_hash_table root;
12   int *dynobj;
13   int *sgot;
14 };
15 
16 struct foo_link_info
17 {
18   struct foo_link_hash_table *hash;
19 };
20 
21 extern void abort (void);
22 
23 int __attribute__((noinline))
foo_create_got_section(int * abfd,struct foo_link_info * info)24 foo_create_got_section (int *abfd, struct foo_link_info *info)
25 {
26   info->hash->sgot = abfd;
27   return 1;
28 }
29 
30 static int *
get_got(int * abfd,struct foo_link_info * info,struct foo_link_hash_table * hash)31 get_got (int *abfd, struct foo_link_info *info,
32 	 struct foo_link_hash_table *hash)
33 {
34   int *got;
35   int *dynobj;
36 
37   got = hash->sgot;
38   if (!got)
39     {
40       dynobj = hash->dynobj;
41       if (!dynobj)
42 	hash->dynobj = dynobj = abfd;
43       if (!foo_create_got_section (dynobj, info))
44 	return 0;
45       got = hash->sgot;
46     }
47   return got;
48 }
49 
50 int * __attribute__((noinline,noclone))
elf64_ia64_check_relocs(int * abfd,struct foo_link_info * info)51 elf64_ia64_check_relocs (int *abfd, struct foo_link_info *info)
52 {
53   return get_got (abfd, info, info->hash);
54 }
55 
56 struct foo_link_info link_info;
57 struct foo_link_hash_table hash;
58 int abfd;
59 
60 int
main()61 main ()
62 {
63   link_info.hash = &hash;
64   if (elf64_ia64_check_relocs (&abfd, &link_info) != &abfd)
65     abort ();
66   return 0;
67 }
68 
69