calling-convention

Retrieving the calling method name from within a method [duplicate]

試著忘記壹切 提交于 2019-11-26 05:54:37
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: How can I find the method that called the current method? I have a method in an object that is called from a number of places within the object. Is there a quick and easy way to get the name of the method that called this popular method. Pseudo Code EXAMPLE: public Main() { PopularMethod(); } public ButtonClick(object sender, EventArgs e) { PopularMethod(); } public Button2Click(object sender, EventArgs e) {

glibc scanf Segmentation faults when called from a function that doesn't align RSP

自古美人都是妖i 提交于 2019-11-26 04:01:41
问题 When compiling below code: global main extern printf, scanf section .data msg: db \"Enter a number: \",10,0 format:db \"%d\",0 section .bss number resb 4 section .text main: mov rdi, msg mov al, 0 call printf mov rsi, number mov rdi, format mov al, 0 call scanf mov rdi,format mov rsi,[number] inc rsi mov rax,0 call printf ret using: nasm -f elf64 example.asm -o example.o gcc -no-pie -m64 example.o -o example and then run ./example it runs, print: enter a number: but then crashes and prints:

What are the different calling conventions in C/C++ and what do each mean?

↘锁芯ラ 提交于 2019-11-26 03:38:33
问题 There are different calling conventions available in C/C++: stdcall , extern , pascal , etc. How many such calling conventions are available, and what do each mean? Are there any links that describe these? 回答1: Neither Standard C nor Standard C++ has such a concept - these are features of specific compilers, linkers and/or operating systems, so you should really indicate which specific technologies you are interested in. 回答2: Simple answer: I use cdecl, stdcall, and fastcall. I seldom use

What registers to save in the ARM C calling convention?

ε祈祈猫儿з 提交于 2019-11-26 01:39:21
问题 It\'s been a while since I last coded arm assembler and I\'m a little rusty on the details. If I call a C function from arm, I only have to worry about saving r0-r3 and lr, right? If the C function uses any other registers, is it responsible for saving those on the stack and restoring them? In other words, the compiler would generate code to do this for C functions. For example if I use r10 in an assembler function, I don\'t have to push its value on the stack, or to memory, and pop/restore

Why does Windows64 use a different calling convention from all other OSes on x86-64?

孤街浪徒 提交于 2019-11-26 01:24:33
问题 AMD has an ABI specification that describes the calling convention to use on x86-64. All OSes follow it, except for Windows which has it\'s own x86-64 calling convention. Why? Does anyone know the technical, historical, or political reasons for this difference, or is it purely a matter of NIHsyndrome? I understand that different OSes may have different needs for higher level things, but that doesn\'t explain why for example the register parameter passing order on Windows is rcx - rdx - r8 -

Where is the x86-64 System V ABI documented?

若如初见. 提交于 2019-11-25 23:28:36
问题 The x86-64 System V ABI (used on everything except Windows) used to live at http://x86-64.org/documentation/abi.pdf, but that site has now fallen off the internet. Is there a new authoritative home for the document? 回答1: The System V x86-64 psABI is maintained on GitHub. H.J. Lu's github page has a wiki with links to the current versions of the x86-64 and i386 SystemV psABI documents, and to the forums where updates are discussed. See the x86 tag wiki for direct links to the latest versions.