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