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 #if defined(_WIN32) && !defined(__CYGWIN__)
43 # define PATH_SEPARATOR ';'
45 # define PATH_SEPARATOR ':'
48 static struct strarray tmp_files
;
49 static struct strarray empty_strarray
;
62 { "amd64", CPU_x86_64
},
63 { "x86_64", CPU_x86_64
},
64 { "powerpc", CPU_POWERPC
},
69 { "arm64", CPU_ARM64
},
70 { "aarch64", CPU_ARM64
},
73 /* atexit handler to clean tmp files */
74 void cleanup_tmp_files(void)
77 for (i
= 0; i
< tmp_files
.count
; i
++) if (tmp_files
.str
[i
]) unlink( tmp_files
.str
[i
] );
81 void *xmalloc (size_t size
)
85 res
= malloc (size
? size
: 1);
88 fprintf (stderr
, "Virtual memory exhausted.\n");
94 void *xrealloc (void *ptr
, size_t size
)
96 void *res
= realloc (ptr
, size
);
97 if (size
&& res
== NULL
)
99 fprintf (stderr
, "Virtual memory exhausted.\n");
105 char *xstrdup( const char *str
)
107 char *res
= strdup( str
);
110 fprintf (stderr
, "Virtual memory exhausted.\n");
116 char *strupper(char *s
)
119 for (p
= s
; *p
; p
++) *p
= toupper(*p
);
123 int strendswith(const char* str
, const char* end
)
127 return l
>= m
&& strcmp(str
+ l
- m
, end
) == 0;
130 char *strmake( const char* fmt
, ... )
138 char *p
= xmalloc( size
);
140 n
= vsnprintf( p
, size
, fmt
, ap
);
142 if (n
== -1) size
*= 2;
143 else if ((size_t)n
>= size
) size
= n
+ 1;
149 static struct strarray
strarray_copy( struct strarray src
)
151 struct strarray array
;
152 array
.count
= src
.count
;
154 array
.str
= xmalloc( array
.max
* sizeof(*array
.str
) );
155 memcpy( array
.str
, src
.str
, array
.count
* sizeof(*array
.str
) );
159 static void strarray_add_one( struct strarray
*array
, const char *str
)
161 if (array
->count
== array
->max
)
164 if (array
->max
< 16) array
->max
= 16;
165 array
->str
= xrealloc( array
->str
, array
->max
* sizeof(*array
->str
) );
167 array
->str
[array
->count
++] = str
;
170 void strarray_add( struct strarray
*array
, ... )
175 va_start( valist
, array
);
176 while ((str
= va_arg( valist
, const char *))) strarray_add_one( array
, str
);
180 void strarray_addv( struct strarray
*array
, char * const *argv
)
182 while (*argv
) strarray_add_one( array
, *argv
++ );
185 void strarray_addall( struct strarray
*array
, struct strarray args
)
189 for (i
= 0; i
< args
.count
; i
++) strarray_add_one( array
, args
.str
[i
] );
192 struct strarray
strarray_fromstring( const char *str
, const char *delim
)
195 struct strarray array
= empty_strarray
;
196 char *buf
= xstrdup( str
);
198 for (tok
= strtok( buf
, delim
); tok
; tok
= strtok( NULL
, delim
))
199 strarray_add_one( &array
, strdup( tok
));
205 void fatal_error( const char *msg
, ... )
208 va_start( valist
, msg
);
211 fprintf( stderr
, "%s:", input_file_name
);
213 fprintf( stderr
, "%d:", current_line
);
214 fputc( ' ', stderr
);
216 else fprintf( stderr
, "winebuild: " );
217 vfprintf( stderr
, msg
, valist
);
222 void fatal_perror( const char *msg
, ... )
225 va_start( valist
, msg
);
228 fprintf( stderr
, "%s:", input_file_name
);
230 fprintf( stderr
, "%d:", current_line
);
231 fputc( ' ', stderr
);
233 vfprintf( stderr
, msg
, valist
);
239 void error( const char *msg
, ... )
242 va_start( valist
, msg
);
245 fprintf( stderr
, "%s:", input_file_name
);
247 fprintf( stderr
, "%d:", current_line
);
248 fputc( ' ', stderr
);
250 vfprintf( stderr
, msg
, valist
);
255 void warning( const char *msg
, ... )
259 if (!display_warnings
) return;
260 va_start( valist
, msg
);
263 fprintf( stderr
, "%s:", input_file_name
);
265 fprintf( stderr
, "%d:", current_line
);
266 fputc( ' ', stderr
);
268 fprintf( stderr
, "warning: " );
269 vfprintf( stderr
, msg
, valist
);
273 int output( const char *format
, ... )
278 va_start( valist
, format
);
279 ret
= vfprintf( output_file
, format
, valist
);
281 if (ret
< 0) fatal_perror( "Output error" );
285 void spawn( struct strarray args
)
290 strarray_add_one( &args
, NULL
);
292 for (i
= 0; args
.str
[i
]; i
++)
293 fprintf( stderr
, "%s%c", args
.str
[i
], args
.str
[i
+1] ? ' ' : '\n' );
295 if ((status
= _spawnvp( _P_WAIT
, args
.str
[0], args
.str
)))
297 if (status
> 0) fatal_error( "%s failed with status %u\n", args
.str
[0], status
);
298 else fatal_perror( "winebuild" );
303 /* find a build tool in the path, trying the various names */
304 struct strarray
find_tool( const char *name
, const char * const *names
)
307 static unsigned int count
, maxlen
;
310 const char *alt_names
[2];
318 /* split the path in directories */
320 if (!getenv( "PATH" )) fatal_error( "PATH not set, cannot find required tools\n" );
321 path
= xstrdup( getenv( "PATH" ));
322 for (p
= path
, count
= 2; *p
; p
++) if (*p
== PATH_SEPARATOR
) count
++;
323 dirs
= xmalloc( count
* sizeof(*dirs
) );
325 dirs
[count
++] = p
= path
;
328 while (*p
&& *p
!= PATH_SEPARATOR
) p
++;
333 for (i
= 0; i
< count
; i
++) maxlen
= max( maxlen
, strlen(dirs
[i
])+2 );
345 len
= strlen(*names
) + sizeof(EXEEXT
) + 1;
347 len
+= strlen(target_alias
) + 1;
348 file
= xmalloc( maxlen
+ len
);
350 for (i
= 0; i
< count
; i
++)
352 strcpy( file
, dirs
[i
] );
353 p
= file
+ strlen(file
);
354 if (p
== file
) *p
++ = '.';
355 if (p
[-1] != '/') *p
++ = '/';
358 strcpy( p
, target_alias
);
365 if (!stat( file
, &st
) && S_ISREG(st
.st_mode
) && (st
.st_mode
& 0111))
367 struct strarray ret
= empty_strarray
;
368 strarray_add_one( &ret
, file
);
375 fatal_error( "cannot find the '%s' tool\n", name
);
378 struct strarray
get_as_command(void)
380 struct strarray args
;
382 if (cc_command
.count
)
384 args
= strarray_copy( cc_command
);
385 strarray_add( &args
, "-xassembler", "-c", NULL
);
386 if (force_pointer_size
)
387 strarray_add_one( &args
, (force_pointer_size
== 8) ? "-m64" : "-m32" );
388 if (cpu_option
) strarray_add_one( &args
, strmake("-mcpu=%s", cpu_option
) );
389 if (arch_option
) strarray_add_one( &args
, strmake("-march=%s", arch_option
) );
393 if (!as_command
.count
)
395 static const char * const commands
[] = { "gas", "as", NULL
};
396 as_command
= find_tool( "as", commands
);
399 args
= strarray_copy( as_command
);
401 if (force_pointer_size
)
403 switch (target_platform
)
406 strarray_add( &args
, "-arch", (force_pointer_size
== 8) ? "x86_64" : "i386", NULL
);
412 strarray_add_one( &args
, (force_pointer_size
== 8) ? "-a64" : "-a32" );
415 strarray_add_one( &args
, (force_pointer_size
== 8) ? "--64" : "--32" );
422 if (cpu_option
) strarray_add_one( &args
, strmake("-mcpu=%s", cpu_option
) );
426 struct strarray
get_ld_command(void)
428 struct strarray args
;
430 if (!ld_command
.count
)
432 static const char * const commands
[] = { "ld", "gld", NULL
};
433 ld_command
= find_tool( "ld", commands
);
436 args
= strarray_copy( ld_command
);
438 if (force_pointer_size
)
440 switch (target_platform
)
443 strarray_add( &args
, "-arch", (force_pointer_size
== 8) ? "x86_64" : "i386", NULL
);
445 case PLATFORM_FREEBSD
:
446 strarray_add( &args
, "-m", (force_pointer_size
== 8) ? "elf_x86_64_fbsd" : "elf_i386_fbsd", NULL
);
452 strarray_add( &args
, "-m", (force_pointer_size
== 8) ? "elf64ppc" : "elf32ppc", NULL
);
455 strarray_add( &args
, "-m", (force_pointer_size
== 8) ? "elf_x86_64" : "elf_i386", NULL
);
464 const char *get_nm_command(void)
466 if (!nm_command
.count
)
468 static const char * const commands
[] = { "nm", "gnm", NULL
};
469 nm_command
= find_tool( "nm", commands
);
471 if (nm_command
.count
> 1)
472 fatal_error( "multiple arguments in nm command not supported yet\n" );
473 return nm_command
.str
[0];
476 /* get a name for a temp file, automatically cleaned up on exit */
477 char *get_temp_file_name( const char *prefix
, const char *suffix
)
480 const char *ext
, *basename
;
483 if (!prefix
|| !prefix
[0]) prefix
= "winebuild";
484 if (!suffix
) suffix
= "";
485 if ((basename
= strrchr( prefix
, '/' ))) basename
++;
486 else basename
= prefix
;
487 if (!(ext
= strchr( basename
, '.' ))) ext
= prefix
+ strlen(prefix
);
488 name
= xmalloc( sizeof("/tmp/") + (ext
- prefix
) + sizeof(".XXXXXX") + strlen(suffix
) );
489 memcpy( name
, prefix
, ext
- prefix
);
490 strcpy( name
+ (ext
- prefix
), ".XXXXXX" );
491 strcat( name
, suffix
);
493 if ((fd
= mkstemps( name
, strlen(suffix
) )) == -1)
495 strcpy( name
, "/tmp/" );
496 memcpy( name
+ 5, basename
, ext
- basename
);
497 strcpy( name
+ 5 + (ext
- basename
), ".XXXXXX" );
498 strcat( name
, suffix
);
499 if ((fd
= mkstemps( name
, strlen(suffix
) )) == -1)
500 fatal_error( "could not generate a temp file\n" );
504 strarray_add_one( &tmp_files
, name
);
508 /*******************************************************************
511 * Function for reading from/writing to a memory buffer.
514 int byte_swapped
= 0;
515 const char *input_buffer_filename
;
516 const unsigned char *input_buffer
;
517 size_t input_buffer_pos
;
518 size_t input_buffer_size
;
519 unsigned char *output_buffer
;
520 size_t output_buffer_pos
;
521 size_t output_buffer_size
;
523 static void check_output_buffer_space( size_t size
)
525 if (output_buffer_pos
+ size
>= output_buffer_size
)
527 output_buffer_size
= max( output_buffer_size
* 2, output_buffer_pos
+ size
);
528 output_buffer
= xrealloc( output_buffer
, output_buffer_size
);
532 void init_input_buffer( const char *file
)
537 if ((fd
= open( file
, O_RDONLY
| O_BINARY
)) == -1) fatal_perror( "Cannot open %s", file
);
538 if ((fstat( fd
, &st
) == -1)) fatal_perror( "Cannot stat %s", file
);
539 if (!st
.st_size
) fatal_error( "%s is an empty file\n", file
);
541 if ((input_buffer
= mmap( NULL
, st
.st_size
, PROT_READ
, MAP_PRIVATE
, fd
, 0 )) == (void*)-1)
544 unsigned char *buffer
= xmalloc( st
.st_size
);
545 if (read( fd
, buffer
, st
.st_size
) != st
.st_size
) fatal_error( "Cannot read %s\n", file
);
546 input_buffer
= buffer
;
549 input_buffer_filename
= xstrdup( file
);
550 input_buffer_size
= st
.st_size
;
551 input_buffer_pos
= 0;
555 void init_output_buffer(void)
557 output_buffer_size
= 1024;
558 output_buffer_pos
= 0;
559 output_buffer
= xmalloc( output_buffer_size
);
562 void flush_output_buffer(void)
564 if (fwrite( output_buffer
, 1, output_buffer_pos
, output_file
) != output_buffer_pos
)
565 fatal_error( "Error writing to %s\n", output_file_name
);
566 free( output_buffer
);
569 unsigned char get_byte(void)
571 if (input_buffer_pos
>= input_buffer_size
)
572 fatal_error( "%s is a truncated file\n", input_buffer_filename
);
573 return input_buffer
[input_buffer_pos
++];
576 unsigned short get_word(void)
580 if (input_buffer_pos
+ sizeof(ret
) > input_buffer_size
)
581 fatal_error( "%s is a truncated file\n", input_buffer_filename
);
582 memcpy( &ret
, input_buffer
+ input_buffer_pos
, sizeof(ret
) );
583 if (byte_swapped
) ret
= (ret
<< 8) | (ret
>> 8);
584 input_buffer_pos
+= sizeof(ret
);
588 unsigned int get_dword(void)
592 if (input_buffer_pos
+ sizeof(ret
) > input_buffer_size
)
593 fatal_error( "%s is a truncated file\n", input_buffer_filename
);
594 memcpy( &ret
, input_buffer
+ input_buffer_pos
, sizeof(ret
) );
596 ret
= ((ret
<< 24) | ((ret
<< 8) & 0x00ff0000) | ((ret
>> 8) & 0x0000ff00) | (ret
>> 24));
597 input_buffer_pos
+= sizeof(ret
);
601 void put_data( const void *data
, size_t size
)
603 check_output_buffer_space( size
);
604 memcpy( output_buffer
+ output_buffer_pos
, data
, size
);
605 output_buffer_pos
+= size
;
608 void put_byte( unsigned char val
)
610 check_output_buffer_space( 1 );
611 output_buffer
[output_buffer_pos
++] = val
;
614 void put_word( unsigned short val
)
616 if (byte_swapped
) val
= (val
<< 8) | (val
>> 8);
617 put_data( &val
, sizeof(val
) );
620 void put_dword( unsigned int val
)
623 val
= ((val
<< 24) | ((val
<< 8) & 0x00ff0000) | ((val
>> 8) & 0x0000ff00) | (val
>> 24));
624 put_data( &val
, sizeof(val
) );
627 void put_qword( unsigned int val
)
641 /* pointer-sized word */
642 void put_pword( unsigned int val
)
644 if (get_ptr_size() == 8) put_qword( val
);
645 else put_dword( val
);
648 void align_output( unsigned int align
)
650 size_t size
= align
- (output_buffer_pos
% align
);
652 if (size
== align
) return;
653 check_output_buffer_space( size
);
654 memset( output_buffer
+ output_buffer_pos
, 0, size
);
655 output_buffer_pos
+= size
;
658 /* output a standard header for generated files */
659 void output_standard_file_header(void)
662 output( "/* File generated automatically from %s; do not edit! */\n", spec_file_name
);
664 output( "/* File generated automatically; do not edit! */\n" );
665 output( "/* This file can be copied, modified and distributed without restriction. */\n\n" );
668 /* dump a byte stream into the assembly code */
669 void dump_bytes( const void *buffer
, unsigned int size
)
672 const unsigned char *ptr
= buffer
;
675 output( "\t.byte " );
676 for (i
= 0; i
< size
- 1; i
++, ptr
++)
678 if ((i
% 16) == 15) output( "0x%02x\n\t.byte ", *ptr
);
679 else output( "0x%02x,", *ptr
);
681 output( "0x%02x\n", *ptr
);
685 /*******************************************************************
688 * Open a file in the given srcdir and set the input_file_name global variable.
690 FILE *open_input_file( const char *srcdir
, const char *name
)
693 FILE *file
= fopen( name
, "r" );
697 fullname
= strmake( "%s/%s", srcdir
, name
);
698 file
= fopen( fullname
, "r" );
700 else fullname
= xstrdup( name
);
702 if (!file
) fatal_error( "Cannot open file '%s'\n", fullname
);
703 input_file_name
= fullname
;
709 /*******************************************************************
712 * Close the current input file (must have been opened with open_input_file).
714 void close_input_file( FILE *file
)
717 free( input_file_name
);
718 input_file_name
= NULL
;
723 /*******************************************************************
724 * remove_stdcall_decoration
726 * Remove a possible @xx suffix from a function name.
727 * Return the numerical value of the suffix, or -1 if none.
729 int remove_stdcall_decoration( char *name
)
731 char *p
, *end
= strrchr( name
, '@' );
732 if (!end
|| !end
[1] || end
== name
) return -1;
733 if (target_cpu
!= CPU_x86
) return -1;
734 /* make sure all the rest is digits */
735 for (p
= end
+ 1; *p
; p
++) if (!isdigit(*p
)) return -1;
737 return atoi( end
+ 1 );
741 /*******************************************************************
744 * Run a file through the assembler.
746 void assemble_file( const char *src_file
, const char *obj_file
)
748 struct strarray args
= get_as_command();
749 strarray_add( &args
, "-o", obj_file
, src_file
, NULL
);
754 /*******************************************************************
757 * Create a new dll spec file descriptor
759 DLLSPEC
*alloc_dll_spec(void)
763 spec
= xmalloc( sizeof(*spec
) );
764 memset( spec
, 0, sizeof(*spec
) );
765 spec
->type
= SPEC_WIN32
;
766 spec
->base
= MAX_ORDINALS
;
767 spec
->characteristics
= IMAGE_FILE_EXECUTABLE_IMAGE
;
769 spec
->subsystem_major
= 4;
770 spec
->subsystem_minor
= 0;
771 if (get_ptr_size() > 4)
772 spec
->characteristics
|= IMAGE_FILE_LARGE_ADDRESS_AWARE
;
774 spec
->characteristics
|= IMAGE_FILE_32BIT_MACHINE
;
775 spec
->dll_characteristics
= IMAGE_DLLCHARACTERISTICS_NX_COMPAT
;
780 /*******************************************************************
783 * Free dll spec file descriptor
785 void free_dll_spec( DLLSPEC
*spec
)
789 for (i
= 0; i
< spec
->nb_entry_points
; i
++)
791 ORDDEF
*odp
= &spec
->entry_points
[i
];
793 free( odp
->export_name
);
794 free( odp
->link_name
);
796 free( spec
->file_name
);
797 free( spec
->dll_name
);
798 free( spec
->c_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 char *make_c_identifier( const char *str
)
815 char *p
, buffer
[256];
817 for (p
= buffer
; *str
&& p
< buffer
+sizeof(buffer
)-1; p
++, str
++)
819 if (isalnum(*str
)) *p
= *str
;
823 return xstrdup( buffer
);
827 /*******************************************************************
830 * Generate an internal name for a stub entry point.
832 const char *get_stub_name( const ORDDEF
*odp
, const DLLSPEC
*spec
)
837 if (odp
->name
|| odp
->export_name
)
840 buffer
= strmake( "__wine_stub_%s", odp
->name
? odp
->name
: odp
->export_name
);
841 /* make sure name is a legal C identifier */
842 for (p
= buffer
; *p
; p
++) if (!isalnum(*p
) && *p
!= '_') break;
843 if (!*p
) return buffer
;
846 buffer
= strmake( "__wine_stub_%s_%d", make_c_identifier(spec
->file_name
), odp
->ordinal
);
850 /* parse a cpu name and return the corresponding value */
851 int get_cpu_from_name( const char *name
)
855 for (i
= 0; i
< sizeof(cpu_names
)/sizeof(cpu_names
[0]); i
++)
856 if (!strcmp( cpu_names
[i
].name
, name
)) return cpu_names
[i
].cpu
;
860 /*****************************************************************
861 * Function: get_alignment
864 * According to the info page for gas, the .align directive behaves
865 * differently on different systems. On some architectures, the
866 * argument of a .align directive is the number of bytes to pad to, so
867 * to align on an 8-byte boundary you'd say
869 * On other systems, the argument is "the number of low-order zero bits
870 * that the location counter must have after advancement." So to
871 * align on an 8-byte boundary you'd say
874 * The reason gas is written this way is that it's trying to mimic
875 * native assemblers for the various architectures it runs on. gas
876 * provides other directives that work consistently across
877 * architectures, but of course we want to work on all arches with or
878 * without gas. Hence this function.
882 * align -- the number of bytes to align to. Must be a power of 2.
884 unsigned int get_alignment(unsigned int align
)
888 assert( !(align
& (align
- 1)) );
894 if (target_platform
!= PLATFORM_APPLE
) return align
;
900 while ((1u << n
) != align
) n
++;
908 /* return the page size for the target CPU */
909 unsigned int get_page_size(void)
926 /* return the size of a pointer on the target CPU */
927 unsigned int get_ptr_size(void)
944 /* return the total size in bytes of the arguments on the stack */
945 unsigned int get_args_size( const ORDDEF
*odp
)
949 for (i
= size
= 0; i
< odp
->u
.func
.nb_args
; i
++)
951 switch (odp
->u
.func
.args
[i
])
958 /* int128 is passed as pointer on x86_64 */
959 if (target_cpu
!= CPU_x86_64
)
966 size
+= get_ptr_size();
973 /* return the assembly name for a C symbol */
974 const char *asm_name( const char *sym
)
978 switch (target_platform
)
981 case PLATFORM_WINDOWS
:
982 if (sym
[0] == '.' && sym
[1] == 'L') return sym
;
984 buffer
= strmake( "_%s", sym
);
991 /* return an assembly function declaration for a C function name */
992 const char *func_declaration( const char *func
)
996 switch (target_platform
)
1000 case PLATFORM_WINDOWS
:
1002 buffer
= strmake( ".def _%s; .scl 2; .type 32; .endef", func
);
1010 buffer
= strmake( ".type %s,%%function", func
);
1013 buffer
= strmake( ".type %s,@function", func
);
1021 /* output a size declaration for an assembly function */
1022 void output_function_size( const char *name
)
1024 switch (target_platform
)
1026 case PLATFORM_APPLE
:
1027 case PLATFORM_WINDOWS
:
1030 output( "\t.size %s, .-%s\n", name
, name
);
1035 /* output a .cfi directive */
1036 void output_cfi( const char *format
, ... )
1040 if (!unwind_tables
) return;
1041 va_start( valist
, format
);
1042 fputc( '\t', output_file
);
1043 vfprintf( output_file
, format
, valist
);
1044 fputc( '\n', output_file
);
1048 /* output the GNU note for non-exec stack */
1049 void output_gnu_stack_note(void)
1051 switch (target_platform
)
1053 case PLATFORM_WINDOWS
:
1054 case PLATFORM_APPLE
:
1061 output( "\t.section .note.GNU-stack,\"\",%%progbits\n" );
1064 output( "\t.section .note.GNU-stack,\"\",@progbits\n" );
1071 /* return a global symbol declaration for an assembly symbol */
1072 const char *asm_globl( const char *func
)
1074 static char *buffer
;
1077 switch (target_platform
)
1079 case PLATFORM_APPLE
:
1080 buffer
= strmake( "\t.globl _%s\n\t.private_extern _%s\n_%s:", func
, func
, func
);
1082 case PLATFORM_WINDOWS
:
1083 buffer
= strmake( "\t.globl _%s\n_%s:", func
, func
);
1086 buffer
= strmake( "\t.globl %s\n\t.hidden %s\n%s:", func
, func
, func
);
1092 const char *get_asm_ptr_keyword(void)
1094 switch(get_ptr_size())
1096 case 4: return ".long";
1097 case 8: return ".quad";
1103 const char *get_asm_string_keyword(void)
1105 switch (target_platform
)
1107 case PLATFORM_APPLE
:
1114 const char *get_asm_rodata_section(void)
1116 switch (target_platform
)
1118 case PLATFORM_APPLE
: return ".const";
1119 default: return ".section .rodata";
1123 const char *get_asm_string_section(void)
1125 switch (target_platform
)
1127 case PLATFORM_APPLE
: return ".cstring";
1128 default: return ".section .rodata";