[PATCH] D148953: [llvm][ADT] Fix Any linker error with multiple compilers

Philippe Renon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 22 04:54:38 PDT 2023


filnet added a comment.

In D148953#4288999 <https://reviews.llvm.org/D148953#4288999>, @dblaikie wrote:

> errrr:
>
>> This can lead to multiple definition linker errors when some object files are compiled with a compiler that puts the variable into .data but they are linked to object files from a different compiler that put the variable into .bss.
>
> When/where/how does this happen? Would this not be an ABI bug in those compilers that needs to be fixed there?

Seems to be a grey area according to wikipedia:

> In C, statically allocated objects without an explicit initializer are initialized to zero (for arithmetic types) or a null pointer (for pointer types). Implementations of C typically represent zero values and null pointer values using a bit pattern consisting solely of zero-valued bits (despite filling bss with zero is not required by the C standard, all variables in .bss are required to be individually initialized to some sort of zeroes according to Section 6.7.8 of C ISO Standard 9899:1999 or section 6.7.9 for newer standards). Hence, the BSS segment typically includes all uninitialized objects (both variables and constants) declared at file scope (i.e., outside any function) as well as uninitialized static local variables (local variables declared with the static keyword); static local constants must be initialized at declaration, however, as they do not have a separate declaration, and thus are typically not in the BSS section, though they may be implicitly or explicitly initialized to zero. An implementation may also assign statically-allocated variables and constants initialized with a value consisting solely of zero-valued bits to the BSS section.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148953/new/

https://reviews.llvm.org/D148953



More information about the llvm-commits mailing list