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
784
votes
17 answers

What is an application binary interface (ABI)?

I never clearly understood what an ABI is. Please don't point me to a Wikipedia article. If I could understand it, I wouldn't be here posting such a lengthy post. This is my mindset about different interfaces: A TV remote is an interface between the…
claws
  • 52,236
  • 58
  • 146
  • 195
567
votes
6 answers

Does the C++ standard allow for an uninitialized bool to crash a program?

I know that an "undefined behaviour" in C++ can pretty much allow the compiler to do anything it wants. However, I had a crash that surprised me, as I assumed that the code was safe enough. In this case, the real problem happened only on a specific…
Remz
  • 3,338
  • 3
  • 7
  • 11
287
votes
12 answers

Difference between API and ABI

I am new to Linux system programming and I came across API and ABI while reading Linux System Programming. Definition of API: An API defines the interfaces by which one piece of software communicates with another at the source level. Definition of…
Searock
  • 6,278
  • 11
  • 62
  • 98
209
votes
13 answers

Why is a boolean 1 byte and not 1 bit of size?

In C++, Why is a boolean 1 byte and not 1 bit of size? Why aren't there types like a 4-bit or 2-bit integers? I'm missing out the above things when writing an emulator for a CPU
Asm
  • 2,101
  • 2
  • 13
  • 4
194
votes
4 answers

What are the calling conventions for UNIX & Linux system calls (and user-space functions) on i386 and x86-64

Following links explain x86-32 system call conventions for both UNIX (BSD flavor) & Linux: http://www.int80h.org/bsdasm/#system-calls http://www.freebsd.org/doc/en/books/developers-handbook/x86-system-calls.html But what are the x86-64 system call…
claws
  • 52,236
  • 58
  • 146
  • 195
189
votes
11 answers

Are there any downsides to passing structs by value in C, rather than passing a pointer?

Are there any downsides to passing structs by value in C, rather than passing a pointer? If the struct is large, there is obviously the performance aspect of copying lots of data, but for a smaller struct, it should basically be the same as passing…
dkagedal
  • 578
  • 2
  • 7
  • 14
156
votes
3 answers

Is it safe to link C++17, C++14, and C++11 objects

Suppose I have three compiled objects, all produced by the same compiler/version: A was compiled with the C++11 standard B was compiled with the C++14 standard C was compiled with the C++17 standard For simplicity, let's assume all headers were…
ricab
  • 2,697
  • 4
  • 23
  • 28
137
votes
4 answers

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

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…
JanKanis
  • 6,346
  • 5
  • 38
  • 42
125
votes
4 answers

How do I safely pass objects, especially STL objects, to and from a DLL?

How do I pass class objects, especially STL objects, to and from a C++ DLL? My application has to interact with third-party plugins in the form of DLL files, and I can't control what compiler these plugins are built with. I'm aware that there's no…
cf-
  • 8,598
  • 9
  • 36
  • 58
116
votes
9 answers

What is the direction of stack growth in most modern systems?

I am preparing some training materials in C and I want my examples to fit the typical stack model. What direction does a C stack grow in Linux, Windows, Mac OSX (PPC and x86), Solaris, and most recent Unixes?
Uri
  • 88,451
  • 51
  • 221
  • 321
104
votes
4 answers

Why can a T* be passed in register, but a unique_ptr cannot?

I'm watching Chandler Carruth's talk in CppCon 2019: There are no Zero-Cost Abstractions in it, he gives the example of how he was surprised by just how much overhead you incur by using an std::unique_ptr over an int*; that segment starts about…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
102
votes
3 answers

What's the difference of section and segment in ELF file format

From wiki Executable and Linkable Format: The segments contain information that is necessary for runtime execution of the file, while sections contain important data for linking and relocation. Any byte in the entire file can be owned by at most…
tsing
  • 1,441
  • 2
  • 12
  • 15
98
votes
1 answer

What exactly does GCC's -Wpsabi option do? What are the implications of supressing it?

Background In the last year I was using the nlohmann json library[1] and was cross-compiling on x86_64 using GCC 5.x arm-linux-gnueabi-* with no warnings. When I updated GCC to a newer version, GCC would generate pages of cryptic diagnostic notes.…
rmc
  • 1,118
  • 1
  • 7
  • 9
88
votes
3 answers

Where is the x86-64 System V ABI documented?

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?
Jeffrey Yasskin
  • 5,171
  • 2
  • 27
  • 39
77
votes
6 answers

What are callee and caller saved registers?

I'm having some trouble understanding the difference between caller and callee saved registers and when to use what. I am using the MSP430 : procedure: mov.w #0,R7 mov.w #0,R6 add.w R6,R7 inc.w R6 cmp.w R12,R6 jl l$loop mov.w R7,R12 ret the…
mugetsu
  • 4,228
  • 9
  • 50
  • 79
1
2 3
59 60