forked from OSchip/llvm-project
[LangRef] Describe linkage types, allocation size of declarations for global variables
Linkage type was only referenced for functions, not for global variables. Clarify that LLVM doesn't make assumption about the allocation size when no definitive initializer for a global variable is known. Differential Revision: https://reviews.llvm.org/D78952
This commit is contained in:
parent
e1815eb2e1
commit
a2247d42e4
|
@ -272,8 +272,8 @@ linkage:
|
|||
visible, meaning that it participates in linkage and can be used to
|
||||
resolve external symbol references.
|
||||
|
||||
It is illegal for a function *declaration* to have any linkage type
|
||||
other than ``external`` or ``extern_weak``.
|
||||
It is illegal for a global variable or function *declaration* to have any
|
||||
linkage type other than ``external`` or ``extern_weak``.
|
||||
|
||||
.. _callingconv:
|
||||
|
||||
|
@ -615,6 +615,8 @@ Global variable definitions must be initialized.
|
|||
Global variables in other translation units can also be declared, in which
|
||||
case they don't have an initializer.
|
||||
|
||||
Global variables can optionally specify a :ref:`linkage type <linkage>`.
|
||||
|
||||
Either global variable definitions or declarations may have an explicit section
|
||||
to be placed in and may have an optional explicit alignment specified. If there
|
||||
is a mismatch between the explicit or inferred section information for the
|
||||
|
@ -686,6 +688,13 @@ assume that the globals are densely packed in their section and try to
|
|||
iterate over them as an array, alignment padding would break this
|
||||
iteration. The maximum alignment is ``1 << 29``.
|
||||
|
||||
For global variables declarations, as well as definitions that may be
|
||||
replaced at link time (``linkonce``, ``weak``, ``extern_weak`` and ``common``
|
||||
linkage types), LLVM makes no assumptions about the allocation size of the
|
||||
variables, except that they may not overlap. The alignment of a global variable
|
||||
declaration or replaceable definition must not be greater than the alignment of
|
||||
the definition it resolves to.
|
||||
|
||||
Globals can also have a :ref:`DLL storage class <dllstorageclass>`,
|
||||
an optional :ref:`runtime preemption specifier <runtime_preemption_model>`,
|
||||
an optional :ref:`global attributes <glattrs>` and
|
||||
|
|
Loading…
Reference in New Issue