VirtualBox

Changeset 95829 in vbox for trunk/include


Ignore:
Timestamp:
Jul 26, 2022 11:13:28 AM (2 years ago)
Author:
vboxsync
Message:

iprt/asmdefs.mac: Changed GLOBALNAME_EX to take three parameter, separating out the visibility attribs and make it use the 'function' type in PE context and 'hidden' visibility as 'private_extern' in Mach-O contexts. The motivation is to mark functions as functions on windows so the linker can mark them as valid control flow targets when /GUARD:CF is enabled. Changed ENDPROC to not mark the end label as a 'function', as that would make it a valid control flow target on windows - which is something it certainly isn't. Added RT_NOTHING as yasm complains if leaving the final parameter of a macro empty otherwise. bugref:10261

File:
1 edited

Legend:

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

    r93115 r95829  
    126126%endmacro
    127127
     128;;
     129; Empty define
     130%define RT_NOTHING
    128131
    129132;; Define ASM_FORMAT_PE64 if applicable.
     
    483486;;
    484487; Global marker which is DECLASM() compatible.
    485 %macro GLOBALNAME_EX 2
    486 %ifndef ASM_FORMAT_BIN
    487  %ifdef ASM_FORMAT_ELF
    488 global NAME(%1):%2
    489  %else
     488;
     489; @param %1     The symbol name - subjected to NAME().
     490; @param %2     ELF and PE attributes: 'function', 'object', 'data', 'notype'.
     491;               PE ignores all but 'function' (yasm only).  Other formats ignores
     492;               this completely.
     493; @param %3     Symbol visibility: 'hidden', 'protected', 'internal', and
     494;                                   RT_NOTHING (for 'default' visibility).
     495;               These are ELF attributes, but 'hidden' is translated to
     496;               'private_extern' for the Macho-O format.
     497;               Ignored by other formats.
     498;
     499%macro GLOBALNAME_EX 3
     500%ifdef ASM_FORMAT_ELF
     501global NAME(%1):%2 %3
     502
     503%elifdef ASM_FORMAT_PE
     504 %ifidn %2,function
     505  %ifdef __YASM__      ; nasm does not support any attributes, it errors out. So, nasm is no good with control flow guard atm.
     506global NAME(%1):function
     507  %else
    490508global NAME(%1)
    491  %endif
    492 %endif
     509  %endif
     510 %else
     511global NAME(%1)
     512 %endif
     513
     514%elifdef ASM_FORMAT_MACHO
     515 %ifidn %3,hidden
     516global NAME(%1):private_extern
     517 %else
     518global NAME(%1)
     519 %endif
     520
     521%elifndef ASM_FORMAT_BIN
     522global NAME(%1)
     523
     524%endif
     525
    493526NAME(%1):
    494527%endmacro
     
    496529;;
    497530; Global exported marker which is DECLASM() compatible.
     531;
     532; @param %1     The symbol name - subjected to NAME().
     533; @param %2     ELF and PE attributes: 'function', 'object', 'data', 'notype'.
     534;               PE ignores all but 'function' (yasm only).  Other formats ignores
     535;               this completely.
     536;
    498537%macro EXPORTEDNAME_EX 2
    499538 %ifdef ASM_FORMAT_PE
     
    505544  %endif
    506545%endif
    507 GLOBALNAME_EX %1, %2
     546GLOBALNAME_EX %1, %2, RT_NOTHING
    508547%endmacro
    509548
     
    518557proc_frame NAME(%1)
    519558 %else
    520 GLOBALNAME_EX %1, function hidden
     559GLOBALNAME_EX %1, function, hidden
    521560 %endif
    522561.start_of_prologue:
     
    547586endproc_frame
    548587 %endif
    549 GLOBALNAME_EX %1 %+ _EndProc, function hidden
     588GLOBALNAME_EX %1 %+ _EndProc, , hidden ; no function here, this isn't a valid code flow target.
    550589%ifdef ASM_FORMAT_ELF
    551590 %ifndef __NASM__ ; nasm does this in the global directive.
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