VirtualBox

Changeset 96368 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Aug 19, 2022 10:55:36 PM (2 years ago)
Author:
vboxsync
Message:

iprt/asmdefs.mac,IPRT/nocrt: Mangling fixes for fastcall compiler support procedures. bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/asmdefs.mac

    r96277 r96368  
    502502
    503503;;
    504 ; Global marker which is DECLASM() compatible.
     504; Same as GLOBALNAME_EX, but without the name mangling.
    505505;
    506506; @param %1     The symbol name - subjected to NAME().
     
    514514;               Ignored by other formats.
    515515;
    516 %macro GLOBALNAME_EX 3
     516%macro GLOBALNAME_RAW 3
    517517%ifdef ASM_FORMAT_ELF
    518 global NAME(%1):%2 %3
     518global %1:%2 %3
    519519
    520520%elifdef ASM_FORMAT_PE
    521521 %ifidn %2,function
    522522  %ifdef __YASM__      ; nasm does not support any attributes, it errors out. So, nasm is no good with control flow guard atm.
    523 global NAME(%1):function
     523global %1:function
    524524  %else
    525 global NAME(%1)
    526   %endif
    527  %else
    528 global NAME(%1)
     525global %1
     526  %endif
     527 %else
     528global %1
    529529 %endif
    530530
    531531%elifdef ASM_FORMAT_MACHO
    532532 %ifidn %3,hidden
    533 global NAME(%1):private_extern
    534  %else
    535 global NAME(%1)
     533global %1:private_extern
     534 %else
     535global %1
    536536 %endif
    537537
    538538%elifndef ASM_FORMAT_BIN
    539 global NAME(%1)
    540 
    541 %endif
    542 
    543 NAME(%1):
    544 %endmacro
    545 
    546 ;;
    547 ; Global exported marker which is DECLASM() compatible.
     539global %1
     540
     541%endif
     542
     543%1:
     544%endmacro
     545
     546;;
     547; Global marker which is DECLASM() compatible.
    548548;
    549549; @param %1     The symbol name - subjected to NAME().
     
    551551;               PE ignores all but 'function' (yasm only).  Other formats ignores
    552552;               this completely.
    553 ;
    554 %macro EXPORTEDNAME_EX 2
     553; @param %3     Symbol visibility: 'hidden', 'protected', 'internal', and
     554;                                   RT_NOTHING (for 'default' visibility).
     555;               These are ELF attributes, but 'hidden' is translated to
     556;               'private_extern' for the Macho-O format.
     557;               Ignored by other formats.
     558;
     559%macro GLOBALNAME_EX 3
     560GLOBALNAME_RAW NAME(%1), %2, %3
     561%endmacro
     562
     563
     564;;
     565; Global exported marker, raw version w/o automatic name mangling.
     566;
     567; @param %1     The internal symbol name.
     568; @param %2     The external symbol name.
     569; @param %3     ELF and PE attributes: 'function', 'object', 'data', 'notype'.
     570;               PE ignores all but 'function' (yasm only).  Other formats ignores
     571;               this completely.
     572;
     573%macro EXPORTEDNAME_RAW 3
    555574 %ifdef ASM_FORMAT_PE
    556   export %1=NAME(%1)
     575  export %2=%1
    557576 %endif
    558577 %ifdef __NASM__
    559578  %ifdef ASM_FORMAT_OMF
    560    export NAME(%1) NAME(%1)
    561   %endif
    562 %endif
    563 GLOBALNAME_EX %1, %2, RT_NOTHING
    564 %endmacro
    565 
    566 ;;
    567 ; Begins a C callable procedure.
    568 %macro BEGINPROC 1
     579   export %1 %2
     580  %endif
     581%endif
     582GLOBALNAME_RAW %1, %3, RT_NOTHING
     583%endmacro
     584
     585;;
     586; Global exported marker which is DECLASM() compatible.
     587;
     588; @param %1     The symbol name - subjected to NAME().
     589; @param %2     ELF and PE attributes: 'function', 'object', 'data', 'notype'.
     590;               PE ignores all but 'function' (yasm only).  Other formats ignores
     591;               this completely.
     592;
     593%macro EXPORTEDNAME_EX 2
     594EXPORTEDNAME_RAW NAME(%1), %1, %2
     595%endmacro
     596
     597
     598;;
     599; Begins a procedure, raw version w/o automatic name mangling.
     600%macro BEGINPROC_RAW 1
    569601 %ifdef RT_ASM_WITH_SEH64_ALT
    570602  SEH64_ALT_START_UNWIND_INFO %1
    571603 %endif
    572604 %ifdef RT_ASM_WITH_SEH64
    573 global     NAME(%1):function
    574 proc_frame NAME(%1)
    575  %else
    576 GLOBALNAME_EX %1, function, hidden
     605global     %1:function
     606proc_frame %1
     607 %else
     608GLOBALNAME_RAW %1, function, hidden
    577609 %endif
    578610.start_of_prologue:
     
    580612
    581613;;
    582 ; Begins a C callable exported procedure.
    583 %macro BEGINPROC_EXPORTED 1
     614; Begins a C callable (DECLASM) procedure.
     615%macro BEGINPROC 1
     616BEGINPROC_RAW NAME(%1)
     617%endmacro
     618
     619
     620;;
     621; Begins a exported procedure, raw version w/o automatic name mangling.
     622; @param 1  Internal name.
     623; @param 2  Exported name.
     624%macro BEGINPROC_EXPORTED_RAW 2
    584625 %ifdef RT_ASM_WITH_SEH64_ALT
    585626  SEH64_ALT_START_UNWIND_INFO %1
     
    587628 %ifdef RT_ASM_WITH_SEH64
    588629  %ifdef ASM_FORMAT_PE
    589 export  %1=NAME(%1)
    590   %endif
    591 global     NAME(%1):function
    592 proc_frame NAME(%1)
    593  %else
    594 EXPORTEDNAME_EX %1, function
     630export  %2=%1
     631  %endif
     632global     %1:function
     633proc_frame %1
     634 %else
     635EXPORTEDNAME_RAW %1, %2, function
    595636 %endif
    596637.start_of_prologue:
     
    598639
    599640;;
    600 ; Ends a C callable procedure.
    601 %macro ENDPROC 1
     641; Begins a C callable (DECLASM) exported procedure.
     642%macro BEGINPROC_EXPORTED 1
     643BEGINPROC_EXPORTED_RAW NAME(%1), %1
     644%endmacro
     645
     646
     647;;
     648; Ends a procedure, raw version w/o automatic name mangling.
     649%macro ENDPROC_RAW 1
    602650 %ifdef RT_ASM_WITH_SEH64
    603651endproc_frame
    604652 %endif
    605 GLOBALNAME_EX %1 %+ _EndProc, , hidden ; no function here, this isn't a valid code flow target.
     653GLOBALNAME_RAW %1 %+ _EndProc, , hidden ; no function here, this isn't a valid code flow target.
    606654%ifdef ASM_FORMAT_ELF
    607655 %ifndef __NASM__ ; nasm does this in the global directive.
    608 size NAME(%1)               NAME(%1 %+ _EndProc) - NAME(%1)
    609 size NAME(%1 %+ _EndProc)   4 ; make it non-zero to shut up warnigns from Linux's objtool.
     656size %1               %1 %+ _EndProc - %1
     657size %1 %+ _EndProc   4 ; make it non-zero to shut up warnigns from Linux's objtool.
    610658 %endif
    611659%endif
     
    621669        section .pdata
    622670   %endif
    623         dd      NAME(%1)                    wrt ..imagebase
    624         dd      NAME(%1 %+ _EndProc)        wrt ..imagebase
    625         dd      NAME(%1 %+ .unwind_info)    wrt ..imagebase
     671        dd      %1                    wrt ..imagebase
     672        dd      %1 %+ _EndProc        wrt ..imagebase
     673        dd      %1 %+ .unwind_info    wrt ..imagebase
    626674
    627675        ; Restore code section.
     
    629677  %endif
    630678 %endif
     679%endmacro
     680
     681;;
     682; Ends a C callable procedure.
     683%macro ENDPROC 1
     684ENDPROC_RAW NAME(%1)
    631685%endmacro
    632686
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette