[PATCH v1 0/1] gas/write.c: add explicitly flag SEC_HAS_CONTENT to object attributes section

Matthieu Longo matthieu.longo@arm.com
Wed Jun 25 14:57:40 GMT 2025


The object attributes section:
- is readonly (SEC_READONLY=1).
- only contains data (SEC_DATA=1).
- does not require the OS to allocate space at runtime (SEC_ALLOC=0).
- does not require the OS to load the section at runtime (SEC_LOAD=0).
- is written out to the output object if it is not empty (SEC_HAS_CONTENT=1).

Today, the setting of SEC_HAS_CONTENT (if not specified by bfd_set_section_flags) occurs a few lines below insidesize_seg (see code below), the last function called in create_obj_attrs_section().

// If this section is not empty (size > 0) and this section
// is not .bss, the flag is set.
  if (size > 0 && ! seginfo->bss)
    flags |= SEC_HAS_CONTENTS;

Setting the flag SEC_HAS_CONTENT via bfd_set_section_flags() instead of relying on the hidden side-effect of size_seg() seems a more maintainable approach due to its explicitness.

Tested on Arm and AArch64. No regression found.

Previous discussion in a previous patch series:
https://inbox.sourceware.org/binutils/20250502103305.3153170-9-matthieu.longo@arm.com/


Matthieu Longo (1):
  gas/write.c: add explicitly flag SEC_HAS_CONTENT to object attributes section

 gas/write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.50.0



More information about the Binutils mailing list