Questions tagged [abi]

The (Application Binary Interface) specifies the low level interface between the programs, libraries and the operating system. E.g. which registers are used to pass function parameters.

The (Application Binary Interface) specifies the low level interface between the programs, libraries and the operating system. E.g. which registers are used to pass function parameters.

890 questions
18
votes
6 answers

Why "long int" has same size as "int"? Does this modifier works at all?

Ehm.. I kind' of though this modifiers like long / short expands / reduces amount of memory allocated when variable are created, but... #include #define test_int int #define long_int long int #define long_long_int long long int void…
Kosmo零
  • 4,001
  • 9
  • 45
  • 88
18
votes
2 answers

Do Visual Studio 2012 updates break C++ ABI?

When Microsoft initially released Visual Studio 2012 in September 2012, they announced their plan for providing updates for Visual Studio on a more regular basis. Since then, they have released Visual Studio 2012 Update 1 (Visual Studio 2012.1) in…
Bloops
  • 485
  • 4
  • 11
18
votes
1 answer

ARM C++ ABI: Constructor/destructor return values

I've been reading through Clang source code and discovered something interesting about the ARM C++ ABI that I can't seem to understand the justification for. From the an online version of the ARM ABI documentation: This ABI requires C1 and C2…
Stephen Lin
  • 5,470
  • 26
  • 48
17
votes
1 answer

Will 'Guaranteed Copy Elision' (P0135, C++1z) potentially require ABI breakage?

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0135r0.html The above proposal for 'Guaranteed Copy Elision' was voted into the C++ working paper in the June 2016 meeting in Oulu, Finland, which was then voted for publication as a committee…
Phil Miller
  • 36,389
  • 13
  • 67
  • 90
17
votes
1 answer

Is it safe to package C++11 software on current Linux distributions?

As a downstream maintainer in a Linux distribution, some of the packages that I usually maintain are starting to use the C++11 features in their code base. All of them depend on different libraries packaged by the Linux distributions. Problems with…
16
votes
2 answers

C++ on x86-64: when are structs/classes passed and returned in registers?

Assuming the x86-64 ABI on Linux, under what conditions in C++ are structs passed to functions in registers vs. on the stack? Under what conditions are they returned in registers? And does the answer change for classes? If it helps simplify the…
jacobsa
  • 5,719
  • 1
  • 28
  • 60
16
votes
2 answers

Does the C++ standard guarantee that a function return value has a constant address?

Consider this program: #include struct S { S() { print(); } void print() { printf("%p\n", (void *) this); } }; S f() { return {}; } int main() { f().print(); } As far as I can tell, there is exactly one S object constructed here.…
user743382
16
votes
3 answers

ARM: Why do I need to push/pop two registers at function calls?

I understand that I need to push the Link Register at the beginning of a function call, and pop that value to the Program Couter before returning, so that the execution can carry one from where it was before the function call. What I don't…
Daniel Scocco
  • 7,036
  • 13
  • 51
  • 78
15
votes
1 answer

Is the Java Native Interface (JNI) affected by C++ ABI compatibility issues?

Is the Java Native Interface (JNI) affected by C++ ABI compatibility issues? I am developing a Java application. I would like to use the Java Native Interface (JNI) to call functions in a C++ library. I have access to the code for the C++ library,…
John V.
  • 403
  • 3
  • 8
15
votes
1 answer

How does adding a private member variable break C++ ABI compatibility?

The pimpl idiom is commonly used in order to allow changing code in dynamically linked libraries without breaking ABI compatibility and having to recompile all the code that depends on the library. Most of the explanations I see mention that adding…
adg
  • 153
  • 5
15
votes
1 answer

ARM to C calling convention, NEON registers to save

There is a similar post that covers regular registers. What about NEON registers. As far as I remember either top half or bottom half of registers have to be preserved across function calls. I can't find that info anywhere, can somebody clarify…
Pavel P
  • 15,789
  • 11
  • 79
  • 128
15
votes
5 answers

Is it valid to write below ESP?

For a 32-bit windows application is it valid to use stack memory below ESP for temporary swap space without explicitly decrementing ESP? Consider a function that returns a floating point value in ST(0). If our value is currently in EAX we would,…
J...
  • 30,968
  • 6
  • 66
  • 143
14
votes
1 answer

Why is stack memory allocated when it is not used?

Consider the following example: struct vector { int size() const; bool empty() const; }; bool vector::empty() const { return size() == 0; } The generated assembly code for vector::empty (by clang, with optimizations): push rax call…
Dr. Gut
  • 2,053
  • 7
  • 26
14
votes
4 answers

How do vararg functions find out the number of arguments in machine code?

How can variadic functions like printf find out the number of arguments they got? The amount of arguments obviously isn't passed as a (hidden) parameter (see a call to printf in asm example here). What's the trick?
masterxilo
  • 2,503
  • 1
  • 30
  • 35
14
votes
2 answers

GCC/Clang x86_64 C++ ABI mismatch when returning a tuple?

When trying to optimize return values on x86_64, I noticed a strange thing. Namely, given the code: #include #include #include using namespace std; constexpr uint64_t a = 1u; constexpr uint64_t b = 2u; pair
jotik
  • 17,044
  • 13
  • 58
  • 123