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

But what’s difference between section and segment? Exactly what you quoted: the segments contain information needed at runtime, while the sections contain information needed during linking. does a segment contain one or more sections? A segment can contain 0 or more sections. Example: readelf -l /bin/date Elf file type is EXEC (Executable file) Entry point … Read more

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

You only need to worry about ABIs when you are crossing library boundaries. Within your own applications/libraries the ABI doesn’t really matter as presumably all your object files are compiled with the same compiler version and switches. If you have a library compiled with ABI1 and an application compiled with ABI2 then the application will … Read more

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

Is this actually an ABI requirement, or maybe it’s just some pessimization in certain scenarios? One example is System V Application Binary Interface AMD64 Architecture Processor Supplement. This ABI is for 64-bit x86-compatible CPUs (Linux x86_64 architecure). It is followed on Solaris, Linux, FreeBSD, macOS, Windows Subsystem for Linux: If a C++ object has either … Read more

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

The short answer to this question is don’t. Because there’s no standard C++ ABI (application binary interface, a standard for calling conventions, data packing/alignment, type size, etc.), you will have to jump through a lot of hoops to try and enforce a standard way of dealing with class objects in your program. There’s not even … Read more

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

Choosing four argument registers on x64 – common to UN*X / Win64 One of the things to keep in mind about x86 is that the register name to “reg number” encoding is not obvious; in terms of instruction encoding (the MOD R/M byte, see http://www.c-jump.com/CIS77/CPU/x86/X77_0060_mod_reg_r_m_byte.htm), register numbers 0…7 are – in that order – ?AX, … Read more

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

For small structs (eg point, rect) passing by value is perfectly acceptable. But, apart from speed, there is one other reason why you should be careful passing/returning large structs by value: Stack space. A lot of C programming is for embedded systems, where memory is at a premium, and stack sizes may be measured in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)