On 4 December 2015 at 20:20, Daryl McDaniel <edk2-li...@mc2research.org> wrote:
[...]
>> On 12/03/15 13:54, Ard Biesheuvel wrote:
>>> The default behavior of the GCC compiler is to emit uninitialized
>>> globals into a COMMON section, where duplicate definitions are merged.
>>> This may result in unexpected behavior, since global variables appearing
>>> by the same name in different C files typically do not refer to the same
>>> conceptual data item.
>
> If the files are being linked together, then this is exactly the correct
> behavior.  If the variables do not refer to the "same conceptual data item"
> then they either have to be renamed or made static.
>

Indeed. This remains true regardless of whether we use -fno-common or
not, and the only difference is that we will flag them rather than let
the compiler silently merge them. And if no instances remain that are
intended uses of COMMON behavior, it no longer matters whether we pass
-fno-common or not.

> This is a common problem when combining code that comes from multiple
> unrelated sources.  Checking for this type of name collision should be part
> of the porting process.
>
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to