2 * Small utility functions for winebuild
4 * Copyright 2000 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
33 #ifdef HAVE_SYS_STAT_H
34 # include <sys/stat.h>
36 #ifdef HAVE_SYS_MMAN_H
42 static const char **tmp_files
;
43 static unsigned int nb_tmp_files
;
44 static unsigned int max_tmp_files
;
57 { "amd64", CPU_x86_64
},
58 { "x86_64", CPU_x86_64
},
59 { "sparc", CPU_SPARC
},
60 { "powerpc", CPU_POWERPC
},
62 { "arm64", CPU_ARM64
},
63 { "aarch64", CPU_ARM64
},
66 /* atexit handler to clean tmp files */
67 void cleanup_tmp_files(void)
70 for (i
= 0; i
< nb_tmp_files
; i
++) if (tmp_files
[i
]) unlink( tmp_files
[i
] );
74 void *xmalloc (size_t size
)
78 res
= malloc (size
? size
: 1);
81 fprintf (stderr
, "Virtual memory exhausted.\n");
87 void *xrealloc (void *ptr
, size_t size
)
89 void *res
= realloc (ptr
, size
);
90 if (size
&& res
== NULL
)
92 fprintf (stderr
, "Virtual memory exhausted.\n");
98 char *xstrdup( const char *str
)
100 char *res
= strdup( str
);
103 fprintf (stderr
, "Virtual memory exhausted.\n");
109 char *strupper(char *s
)
112 for (p
= s
; *p
; p
++) *p
= toupper(*p
);
116 int strendswith(const char* str
, const char* end
)
120 return l
>= m
&& strcmp(str
+ l
- m
, end
) == 0;
123 char *strmake( const char* fmt
, ... )
131 char *p
= xmalloc( size
);
133 n
= vsnprintf( p
, size
, fmt
, ap
);
135 if (n
== -1) size
*= 2;
136 else if ((size_t)n
>= size
) size
= n
+ 1;
142 struct strarray
*strarray_init(void)
144 struct strarray
*array
= xmalloc( sizeof(*array
) );
147 array
->str
= xmalloc( array
->max
* sizeof(*array
->str
) );
151 static void strarray_add_one( struct strarray
*array
, const char *str
)
153 if (array
->count
== array
->max
)
156 array
->str
= xrealloc( array
->str
, array
->max
* sizeof(*array
->str
) );
158 array
->str
[array
->count
++] = str
;
161 void strarray_add( struct strarray
*array
, ... )
166 va_start( valist
, array
);
167 while ((str
= va_arg( valist
, const char *))) strarray_add_one( array
, str
);
171 void strarray_addv( struct strarray
*array
, char * const *argv
)
173 while (*argv
) strarray_add_one( array
, *argv
++ );
176 void strarray_free( struct strarray
*array
)
182 void fatal_error( const char *msg
, ... )
185 va_start( valist
, msg
);
188 fprintf( stderr
, "%s:", input_file_name
);
190 fprintf( stderr
, "%d:", current_line
);
191 fputc( ' ', stderr
);
193 else fprintf( stderr
, "winebuild: " );
194 vfprintf( stderr
, msg
, valist
);
199 void fatal_perror( const char *msg
, ... )
202 va_start( valist
, msg
);
205 fprintf( stderr
, "%s:", input_file_name
);
207 fprintf( stderr
, "%d:", current_line
);
208 fputc( ' ', stderr
);
210 vfprintf( stderr
, msg
, valist
);
216 void error( const char *msg
, ... )
219 va_start( valist
, msg
);
222 fprintf( stderr
, "%s:", input_file_name
);
224 fprintf( stderr
, "%d:", current_line
);
225 fputc( ' ', stderr
);
227 vfprintf( stderr
, msg
, valist
);
232 void warning( const char *msg
, ... )
236 if (!display_warnings
) return;
237 va_start( valist
, msg
);
240 fprintf( stderr
, "%s:", input_file_name
);
242 fprintf( stderr
, "%d:", current_line
);
243 fputc( ' ', stderr
);
245 fprintf( stderr
, "warning: " );
246 vfprintf( stderr
, msg
, valist
);
250 int output( const char *format
, ... )
255 va_start( valist
, format
);
256 ret
= vfprintf( output_file
, format
, valist
);
258 if (ret
< 0) fatal_perror( "Output error" );
262 void spawn( struct strarray
*args
)
267 strarray_add_one( args
, NULL
);
269 for (i
= 0; args
->str
[i
]; i
++)
270 fprintf( stderr
, "%s%c", args
->str
[i
], args
->str
[i
+1] ? ' ' : '\n' );
272 if ((status
= spawnvp( _P_WAIT
, args
->str
[0], args
->str
)))
274 if (status
> 0) fatal_error( "%s failed with status %u\n", args
->str
[0], status
);
275 else fatal_perror( "winebuild" );
280 /* find a build tool in the path, trying the various names */
281 char *find_tool( const char *name
, const char * const *names
)
284 static unsigned int count
, maxlen
;
287 const char *alt_names
[2];
295 /* split the path in directories */
297 if (!getenv( "PATH" )) return NULL
;
298 path
= xstrdup( getenv( "PATH" ));
299 for (p
= path
, count
= 2; *p
; p
++) if (*p
== ':') count
++;
300 dirs
= xmalloc( count
* sizeof(*dirs
) );
302 dirs
[count
++] = p
= path
;
305 while (*p
&& *p
!= ':') p
++;
310 for (i
= 0; i
< count
; i
++) maxlen
= max( maxlen
, strlen(dirs
[i
])+2 );
322 len
= strlen(*names
) + sizeof(EXEEXT
) + 1;
324 len
+= strlen(target_alias
) + 1;
325 file
= xmalloc( maxlen
+ len
);
327 for (i
= 0; i
< count
; i
++)
329 strcpy( file
, dirs
[i
] );
330 p
= file
+ strlen(file
);
331 if (p
== file
) *p
++ = '.';
332 if (p
[-1] != '/') *p
++ = '/';
335 strcpy( p
, target_alias
);
342 if (!stat( file
, &st
) && S_ISREG(st
.st_mode
) && (st
.st_mode
& 0111)) return file
;
350 struct strarray
*get_as_command(void)
352 static int as_is_clang
= 0;
353 struct strarray
*args
= strarray_init();
357 as_command
= find_tool( "clang", NULL
);
358 if (as_command
) as_is_clang
= 1;
363 static const char * const commands
[] = { "gas", "as", NULL
};
364 as_command
= find_tool( "as", commands
);
368 fatal_error( "cannot find suitable assembler\n" );
370 strarray_add_one( args
, as_command
);
374 strarray_add( args
, "-xassembler", "-c", NULL
);
375 if (force_pointer_size
)
376 strarray_add_one( args
, (force_pointer_size
== 8) ? "-m64" : "-m32" );
378 else if (force_pointer_size
)
380 switch (target_platform
)
383 strarray_add( args
, "-arch", (force_pointer_size
== 8) ? "x86_64" : "i386", NULL
);
389 strarray_add_one( args
, (force_pointer_size
== 8) ? "-a64" : "-a32" );
392 strarray_add_one( args
, (force_pointer_size
== 8) ? "--64" : "--32" );
399 if (cpu_option
) strarray_add_one( args
, strmake("-mcpu=%s", cpu_option
) );
403 struct strarray
*get_ld_command(void)
405 struct strarray
*args
= strarray_init();
409 static const char * const commands
[] = { "ld", "gld", NULL
};
410 ld_command
= find_tool( "ld", commands
);
414 fatal_error( "cannot find suitable linker\n" );
416 strarray_add_one( args
, ld_command
);
418 if (force_pointer_size
)
420 switch (target_platform
)
423 strarray_add( args
, "-arch", (force_pointer_size
== 8) ? "x86_64" : "i386", NULL
);
425 case PLATFORM_FREEBSD
:
426 strarray_add( args
, "-m", (force_pointer_size
== 8) ? "elf_x86_64_fbsd" : "elf_i386_fbsd", NULL
);
432 strarray_add( args
, "-m", (force_pointer_size
== 8) ? "elf64ppc" : "elf32ppc", NULL
);
435 strarray_add( args
, "-m", (force_pointer_size
== 8) ? "elf_x86_64" : "elf_i386", NULL
);
444 const char *get_nm_command(void)
448 static const char * const commands
[] = { "nm", "gnm", NULL
};
449 nm_command
= find_tool( "nm", commands
);
453 fatal_error( "cannot find suitable name lister\n" );
457 /* get a name for a temp file, automatically cleaned up on exit */
458 char *get_temp_file_name( const char *prefix
, const char *suffix
)
461 const char *ext
, *basename
;
464 if (!prefix
|| !prefix
[0]) prefix
= "winebuild";
465 if (!suffix
) suffix
= "";
466 if ((basename
= strrchr( prefix
, '/' ))) basename
++;
467 else basename
= prefix
;
468 if (!(ext
= strchr( basename
, '.' ))) ext
= prefix
+ strlen(prefix
);
469 name
= xmalloc( sizeof("/tmp/") + (ext
- prefix
) + sizeof(".XXXXXX") + strlen(suffix
) );
470 memcpy( name
, prefix
, ext
- prefix
);
471 strcpy( name
+ (ext
- prefix
), ".XXXXXX" );
472 strcat( name
, suffix
);
474 if ((fd
= mkstemps( name
, strlen(suffix
) )) == -1)
476 strcpy( name
, "/tmp/" );
477 memcpy( name
+ 5, basename
, ext
- basename
);
478 strcpy( name
+ 5 + (ext
- basename
), ".XXXXXX" );
479 strcat( name
, suffix
);
480 if ((fd
= mkstemps( name
, strlen(suffix
) )) == -1)
481 fatal_error( "could not generate a temp file\n" );
485 if (nb_tmp_files
>= max_tmp_files
)
487 max_tmp_files
= max( 2 * max_tmp_files
, 8 );
488 tmp_files
= xrealloc( tmp_files
, max_tmp_files
* sizeof(tmp_files
[0]) );
490 tmp_files
[nb_tmp_files
++] = name
;
494 /*******************************************************************
497 * Function for reading from/writing to a memory buffer.
500 int byte_swapped
= 0;
501 const char *input_buffer_filename
;
502 const unsigned char *input_buffer
;
503 size_t input_buffer_pos
;
504 size_t input_buffer_size
;
505 unsigned char *output_buffer
;
506 size_t output_buffer_pos
;
507 size_t output_buffer_size
;
509 static void check_output_buffer_space( size_t size
)
511 if (output_buffer_pos
+ size
>= output_buffer_size
)
513 output_buffer_size
= max( output_buffer_size
* 2, output_buffer_pos
+ size
);
514 output_buffer
= xrealloc( output_buffer
, output_buffer_size
);
518 void init_input_buffer( const char *file
)
523 if ((fd
= open( file
, O_RDONLY
| O_BINARY
)) == -1) fatal_perror( "Cannot open %s", file
);
524 if ((fstat( fd
, &st
) == -1)) fatal_perror( "Cannot stat %s", file
);
525 if (!st
.st_size
) fatal_error( "%s is an empty file\n", file
);
527 if ((input_buffer
= mmap( NULL
, st
.st_size
, PROT_READ
, MAP_PRIVATE
, fd
, 0 )) == (void*)-1)
530 unsigned char *buffer
= xmalloc( st
.st_size
);
531 if (read( fd
, buffer
, st
.st_size
) != st
.st_size
) fatal_error( "Cannot read %s\n", file
);
532 input_buffer
= buffer
;
535 input_buffer_filename
= xstrdup( file
);
536 input_buffer_size
= st
.st_size
;
537 input_buffer_pos
= 0;
541 void init_output_buffer(void)
543 output_buffer_size
= 1024;
544 output_buffer_pos
= 0;
545 output_buffer
= xmalloc( output_buffer_size
);
548 void flush_output_buffer(void)
550 if (fwrite( output_buffer
, 1, output_buffer_pos
, output_file
) != output_buffer_pos
)
551 fatal_error( "Error writing to %s\n", output_file_name
);
552 free( output_buffer
);
555 unsigned char get_byte(void)
557 if (input_buffer_pos
>= input_buffer_size
)
558 fatal_error( "%s is a truncated file\n", input_buffer_filename
);
559 return input_buffer
[input_buffer_pos
++];
562 unsigned short get_word(void)
566 if (input_buffer_pos
+ sizeof(ret
) > input_buffer_size
)
567 fatal_error( "%s is a truncated file\n", input_buffer_filename
);
568 memcpy( &ret
, input_buffer
+ input_buffer_pos
, sizeof(ret
) );
569 if (byte_swapped
) ret
= (ret
<< 8) | (ret
>> 8);
570 input_buffer_pos
+= sizeof(ret
);
574 unsigned int get_dword(void)
578 if (input_buffer_pos
+ sizeof(ret
) > input_buffer_size
)
579 fatal_error( "%s is a truncated file\n", input_buffer_filename
);
580 memcpy( &ret
, input_buffer
+ input_buffer_pos
, sizeof(ret
) );
582 ret
= ((ret
<< 24) | ((ret
<< 8) & 0x00ff0000) | ((ret
>> 8) & 0x0000ff00) | (ret
>> 24));
583 input_buffer_pos
+= sizeof(ret
);
587 void put_data( const void *data
, size_t size
)
589 check_output_buffer_space( size
);
590 memcpy( output_buffer
+ output_buffer_pos
, data
, size
);
591 output_buffer_pos
+= size
;
594 void put_byte( unsigned char val
)
596 check_output_buffer_space( 1 );
597 output_buffer
[output_buffer_pos
++] = val
;
600 void put_word( unsigned short val
)
602 if (byte_swapped
) val
= (val
<< 8) | (val
>> 8);
603 put_data( &val
, sizeof(val
) );
606 void put_dword( unsigned int val
)
609 val
= ((val
<< 24) | ((val
<< 8) & 0x00ff0000) | ((val
>> 8) & 0x0000ff00) | (val
>> 24));
610 put_data( &val
, sizeof(val
) );
613 void put_qword( unsigned int val
)
627 /* pointer-sized word */
628 void put_pword( unsigned int val
)
630 if (get_ptr_size() == 8) put_qword( val
);
631 else put_dword( val
);
634 void align_output( unsigned int align
)
636 size_t size
= align
- (output_buffer_pos
% align
);
638 if (size
== align
) return;
639 check_output_buffer_space( size
);
640 memset( output_buffer
+ output_buffer_pos
, 0, size
);
641 output_buffer_pos
+= size
;
644 /* output a standard header for generated files */
645 void output_standard_file_header(void)
648 output( "/* File generated automatically from %s; do not edit! */\n", spec_file_name
);
650 output( "/* File generated automatically; do not edit! */\n" );
651 output( "/* This file can be copied, modified and distributed without restriction. */\n\n" );
654 /* dump a byte stream into the assembly code */
655 void dump_bytes( const void *buffer
, unsigned int size
)
658 const unsigned char *ptr
= buffer
;
661 output( "\t.byte " );
662 for (i
= 0; i
< size
- 1; i
++, ptr
++)
664 if ((i
% 16) == 15) output( "0x%02x\n\t.byte ", *ptr
);
665 else output( "0x%02x,", *ptr
);
667 output( "0x%02x\n", *ptr
);
671 /*******************************************************************
674 * Open a file in the given srcdir and set the input_file_name global variable.
676 FILE *open_input_file( const char *srcdir
, const char *name
)
679 FILE *file
= fopen( name
, "r" );
683 fullname
= strmake( "%s/%s", srcdir
, name
);
684 file
= fopen( fullname
, "r" );
686 else fullname
= xstrdup( name
);
688 if (!file
) fatal_error( "Cannot open file '%s'\n", fullname
);
689 input_file_name
= fullname
;
695 /*******************************************************************
698 * Close the current input file (must have been opened with open_input_file).
700 void close_input_file( FILE *file
)
703 free( input_file_name
);
704 input_file_name
= NULL
;
709 /*******************************************************************
710 * remove_stdcall_decoration
712 * Remove a possible @xx suffix from a function name.
713 * Return the numerical value of the suffix, or -1 if none.
715 int remove_stdcall_decoration( char *name
)
717 char *p
, *end
= strrchr( name
, '@' );
718 if (!end
|| !end
[1] || end
== name
) return -1;
719 if (target_cpu
!= CPU_x86
) return -1;
720 /* make sure all the rest is digits */
721 for (p
= end
+ 1; *p
; p
++) if (!isdigit(*p
)) return -1;
723 return atoi( end
+ 1 );
727 /*******************************************************************
730 * Run a file through the assembler.
732 void assemble_file( const char *src_file
, const char *obj_file
)
734 struct strarray
*args
= get_as_command();
735 strarray_add( args
, "-o", obj_file
, src_file
, NULL
);
737 strarray_free( args
);
741 /*******************************************************************
744 * Create a new dll spec file descriptor
746 DLLSPEC
*alloc_dll_spec(void)
750 spec
= xmalloc( sizeof(*spec
) );
751 spec
->file_name
= NULL
;
752 spec
->dll_name
= NULL
;
753 spec
->init_func
= NULL
;
754 spec
->main_module
= NULL
;
755 spec
->type
= SPEC_WIN32
;
756 spec
->base
= MAX_ORDINALS
;
758 spec
->stack_size
= 0;
760 spec
->nb_entry_points
= 0;
761 spec
->alloc_entry_points
= 0;
763 spec
->nb_resources
= 0;
764 spec
->characteristics
= IMAGE_FILE_EXECUTABLE_IMAGE
;
765 if (get_ptr_size() > 4)
766 spec
->characteristics
|= IMAGE_FILE_LARGE_ADDRESS_AWARE
;
768 spec
->characteristics
|= IMAGE_FILE_32BIT_MACHINE
;
769 spec
->dll_characteristics
= IMAGE_DLLCHARACTERISTICS_NX_COMPAT
;
771 spec
->subsystem_major
= 4;
772 spec
->subsystem_minor
= 0;
773 spec
->entry_points
= NULL
;
775 spec
->ordinals
= NULL
;
776 spec
->resources
= NULL
;
781 /*******************************************************************
784 * Free dll spec file descriptor
786 void free_dll_spec( DLLSPEC
*spec
)
790 for (i
= 0; i
< spec
->nb_entry_points
; i
++)
792 ORDDEF
*odp
= &spec
->entry_points
[i
];
794 free( odp
->export_name
);
795 free( odp
->link_name
);
797 free( spec
->file_name
);
798 free( spec
->dll_name
);
799 free( spec
->init_func
);
800 free( spec
->entry_points
);
802 free( spec
->ordinals
);
803 free( spec
->resources
);
808 /*******************************************************************
811 * Map a string to a valid C identifier.
813 const char *make_c_identifier( const char *str
)
815 static char buffer
[256];
818 for (p
= buffer
; *str
&& p
< buffer
+sizeof(buffer
)-1; p
++, str
++)
820 if (isalnum(*str
)) *p
= *str
;
828 /*******************************************************************
831 * Generate an internal name for a stub entry point.
833 const char *get_stub_name( const ORDDEF
*odp
, const DLLSPEC
*spec
)
838 if (odp
->name
|| odp
->export_name
)
841 buffer
= strmake( "__wine_stub_%s", odp
->name
? odp
->name
: odp
->export_name
);
842 /* make sure name is a legal C identifier */
843 for (p
= buffer
; *p
; p
++) if (!isalnum(*p
) && *p
!= '_') break;
844 if (!*p
) return buffer
;
847 buffer
= strmake( "__wine_stub_%s_%d", make_c_identifier(spec
->file_name
), odp
->ordinal
);
851 /* parse a cpu name and return the corresponding value */
852 enum target_cpu
get_cpu_from_name( const char *name
)
856 for (i
= 0; i
< sizeof(cpu_names
)/sizeof(cpu_names
[0]); i
++)
857 if (!strcmp( cpu_names
[i
].name
, name
)) return cpu_names
[i
].cpu
;
861 /*****************************************************************
862 * Function: get_alignment
865 * According to the info page for gas, the .align directive behaves
866 * differently on different systems. On some architectures, the
867 * argument of a .align directive is the number of bytes to pad to, so
868 * to align on an 8-byte boundary you'd say
870 * On other systems, the argument is "the number of low-order zero bits
871 * that the location counter must have after advancement." So to
872 * align on an 8-byte boundary you'd say
875 * The reason gas is written this way is that it's trying to mimick
876 * native assemblers for the various architectures it runs on. gas
877 * provides other directives that work consistently across
878 * architectures, but of course we want to work on all arches with or
879 * without gas. Hence this function.
883 * align -- the number of bytes to align to. Must be a power of 2.
885 unsigned int get_alignment(unsigned int align
)
889 assert( !(align
& (align
- 1)) );
896 if (target_platform
!= PLATFORM_APPLE
) return align
;
902 while ((1u << n
) != align
) n
++;
910 /* return the page size for the target CPU */
911 unsigned int get_page_size(void)
915 case CPU_x86
: return 4096;
916 case CPU_x86_64
: return 4096;
917 case CPU_POWERPC
: return 4096;
918 case CPU_ARM
: return 4096;
919 case CPU_ARM64
: return 4096;
920 case CPU_SPARC
: return 8192;
927 /* return the size of a pointer on the target CPU */
928 unsigned int get_ptr_size(void)
946 /* return the total size in bytes of the arguments on the stack */
947 unsigned int get_args_size( const ORDDEF
*odp
)
951 for (i
= size
= 0; i
< odp
->u
.func
.nb_args
; i
++)
953 switch (odp
->u
.func
.args
[i
])
960 /* int128 is passed as pointer on x86_64 */
961 if (target_cpu
!= CPU_x86_64
)
968 size
+= get_ptr_size();
975 /* return the assembly name for a C symbol */
976 const char *asm_name( const char *sym
)
980 switch (target_platform
)
983 case PLATFORM_WINDOWS
:
984 if (sym
[0] == '.' && sym
[1] == 'L') return sym
;
986 buffer
= strmake( "_%s", sym
);
993 /* return an assembly function declaration for a C function name */
994 const char *func_declaration( const char *func
)
998 switch (target_platform
)
1000 case PLATFORM_APPLE
:
1002 case PLATFORM_WINDOWS
:
1004 buffer
= strmake( ".def _%s; .scl 2; .type 32; .endef", func
);
1012 buffer
= strmake( ".type %s,%%function", func
);
1015 buffer
= strmake( ".type %s,@function", func
);
1023 /* output a size declaration for an assembly function */
1024 void output_function_size( const char *name
)
1026 switch (target_platform
)
1028 case PLATFORM_APPLE
:
1029 case PLATFORM_WINDOWS
:
1032 output( "\t.size %s, .-%s\n", name
, name
);
1037 /* output a .cfi directive */
1038 void output_cfi( const char *format
, ... )
1042 if (!unwind_tables
) return;
1043 va_start( valist
, format
);
1044 fputc( '\t', output_file
);
1045 vfprintf( output_file
, format
, valist
);
1046 fputc( '\n', output_file
);
1050 /* output the GNU note for non-exec stack */
1051 void output_gnu_stack_note(void)
1053 switch (target_platform
)
1055 case PLATFORM_WINDOWS
:
1056 case PLATFORM_APPLE
:
1063 output( "\t.section .note.GNU-stack,\"\",%%progbits\n" );
1066 output( "\t.section .note.GNU-stack,\"\",@progbits\n" );
1073 /* return a global symbol declaration for an assembly symbol */
1074 const char *asm_globl( const char *func
)
1076 static char *buffer
;
1079 switch (target_platform
)
1081 case PLATFORM_APPLE
:
1082 buffer
= strmake( "\t.globl _%s\n\t.private_extern _%s\n_%s:", func
, func
, func
);
1084 case PLATFORM_WINDOWS
:
1085 buffer
= strmake( "\t.globl _%s\n_%s:", func
, func
);
1088 buffer
= strmake( "\t.globl %s\n\t.hidden %s\n%s:", func
, func
, func
);
1094 const char *get_asm_ptr_keyword(void)
1096 switch(get_ptr_size())
1098 case 4: return ".long";
1099 case 8: return ".quad";
1105 const char *get_asm_string_keyword(void)
1107 switch (target_platform
)
1109 case PLATFORM_APPLE
:
1116 const char *get_asm_short_keyword(void)
1118 switch (target_platform
)
1120 default: return ".short";
1124 const char *get_asm_rodata_section(void)
1126 switch (target_platform
)
1128 case PLATFORM_APPLE
: return ".const";
1129 default: return ".section .rodata";
1133 const char *get_asm_string_section(void)
1135 switch (target_platform
)
1137 case PLATFORM_APPLE
: return ".cstring";
1138 default: return ".section .rodata";