+2020-03-21 Iain Sandoe <iain@sandoe.co.uk>
+
+ * config/darwin.c (darwin_mergeable_constant_section): Collect
+ section anchor checks into the caller.
+ (machopic_select_section): Collect section anchor checks into
+ the determination of 'effective zero-size' objects. When the
+ size is unknown, assume it is non-zero, and thus return the
+ 'generic' section for the DECL.
+
2020-03-21 Iain Sandoe <iain@sandoe.co.uk>
PR target/93694
machine_mode mode = DECL_MODE (exp);
unsigned int modesize = GET_MODE_BITSIZE (mode);
- if (DARWIN_SECTION_ANCHORS
- && flag_section_anchors
- && zsize)
+ if (zsize)
return darwin_sections[zobj_const_section];
if (flag_merge_constants
&& DECL_WEAK (decl)
&& !lookup_attribute ("weak_import", DECL_ATTRIBUTES (decl)));
- zsize = (DECL_P (decl)
+ /* Darwin pads zero-sized objects with at least one byte, so that the ld64
+ atom model is preserved (objects must have distinct regions starting with
+ a unique linker-visible symbol).
+ In order to support section anchors, we need to move objects with zero
+ size into sections which are marked as "no section anchors"; the padded
+ objects, obviously, have real sizes that differ from their DECL sizes. */
+ zsize = DARWIN_SECTION_ANCHORS && flag_section_anchors;
+
+ /* In the streaming of LTO symbol data, we might have a situation where the
+ var is incomplete or layout not finished (DECL_SIZE_UNIT is NULL_TREE).
+ We cannot tell if it is zero-sized then, but we can get the section
+ category correct so that nm reports the right kind of section
+ (e.g. BSS c.f. data). */
+ zsize = (zsize
+ && DECL_P (decl)
&& (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == CONST_DECL)
+ && DECL_SIZE_UNIT (decl)
&& tree_to_uhwi (DECL_SIZE_UNIT (decl)) == 0);
one = DECL_P (decl)
else
base_section = darwin_sections[data_coal_section];
}
- else if (DARWIN_SECTION_ANCHORS
- && flag_section_anchors
- && zsize)
+ else if (zsize)
{
/* If we're doing section anchors, then punt zero-sized objects into
their own sections so that they don't interfere with offset
- computation for the remaining vars. This does not need to be done
- for stuff in mergeable sections, since these are ineligible for
- anchors. */
+ computation for the remaining vars. */
if (ro)
base_section = darwin_sections[zobj_const_data_section];
else