Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/20020404-1.c

raw
1 /* { dg-require-effective-target int32plus } */
2 /* { dg-additional-options "-std=gnu17" } */
3 /* { dg-skip-if "pointers can be truncated" { m32c-*-* } } */
4 /* Extracted from GDB sources. */
5
6 void abort (void);
7 void exit (int);
8
9 typedef long long bfd_signed_vma;
10 typedef bfd_signed_vma file_ptr;
11
12 typedef enum bfd_boolean {false, true} boolean;
13
14 typedef unsigned long long bfd_size_type;
15
16 typedef unsigned int flagword;
17
18 typedef unsigned long long CORE_ADDR;
19 typedef unsigned long long bfd_vma;
20
21 struct bfd_struct {
22 int x;
23 };
24
25 struct asection_struct {
26 unsigned int user_set_vma : 1;
27 bfd_vma vma;
28 bfd_vma lma;
29 unsigned int alignment_power;
30 unsigned int entsize;
31 };
32
33 typedef struct bfd_struct bfd;
34 typedef struct asection_struct asection;
35
36 static bfd *
37 bfd_openw_with_cleanup (char *filename, const char *target, char *mode);
38
39 static asection *
40 bfd_make_section_anyway (bfd *abfd, const char *name);
41
42 static boolean
43 bfd_set_section_size (bfd *abfd, asection *sec, bfd_size_type val);
44
45 static boolean
46 bfd_set_section_flags (bfd *abfd, asection *sec, flagword flags);
47
48 static boolean
49 bfd_set_section_contents (bfd *abfd, asection *section, void * data, file_ptr offset, bfd_size_type count);
50
51 static void
52 dump_bfd_file (char *filename, char *mode,
53 char *target, CORE_ADDR vaddr,
54 char *buf, int len)
55 {
56 bfd *obfd;
57 asection *osection;
58
59 obfd = bfd_openw_with_cleanup (filename, target, mode);
60 osection = bfd_make_section_anyway (obfd, ".newsec");
61 bfd_set_section_size (obfd, osection, len);
62 (((osection)->vma = (osection)->lma= (vaddr)), ((osection)->user_set_vma = (boolean)true), true);
63 (((osection)->alignment_power = (0)),true);
64 bfd_set_section_flags (obfd, osection, 0x203);
65 osection->entsize = 0;
66 bfd_set_section_contents (obfd, osection, buf, 0, len);
67 }
68
69 static bfd *
70 bfd_openw_with_cleanup (char *filename, const char *target, char *mode)
71 {
72 static bfd foo_bfd = { 0 };
73 return &foo_bfd;
74 }
75
76 static asection *
77 bfd_make_section_anyway (bfd *abfd, const char *name)
78 {
79 static asection foo_section = { false, 0x0, 0x0, 0 };
80
81 return &foo_section;
82 }
83
84 static boolean
85 bfd_set_section_size (bfd *abfd, asection *sec, bfd_size_type val)
86 {
87 return true;
88 }
89
90 static boolean
91 bfd_set_section_flags (bfd *abfd, asection *sec, flagword flags)
92 {
93 }
94
95 static boolean
96 bfd_set_section_contents (bfd *abfd, asection *section, void * data, file_ptr offset, bfd_size_type count)
97 {
98 if (count != (bfd_size_type)0x1eadbeef)
99 abort();
100 }
101
102 static char hello[] = "hello";
103
104 int main(void)
105 {
106 dump_bfd_file(0, 0, 0, (CORE_ADDR)0xdeadbeef, hello, (int)0x1eadbeef);
107 exit(0);
108 }