- addr, poff, pshndx, &in_tls);
- if (i < static_cast<int>(ORDER_SMALL_BSS))
- {
- this->filesz_ = *poff - orig_off;
- off = *poff;
- }
+ addr, poff, &foff, pshndx,
+ &in_tls);
+
+ // FOFF tracks the last offset used for the file image,
+ // and *POFF tracks the last offset used for the memory image.
+ // When not using a linker script, bss sections should all
+ // be processed in the ORDER_SMALL_BSS and later buckets.
+ gold_assert(*poff == foff
+ || i == static_cast<int>(ORDER_TLS_BSS)
+ || i >= static_cast<int>(ORDER_SMALL_BSS)
+ || layout->script_options()->saw_sections_clause());
+
+ this->filesz_ = foff - orig_off;
+ off = foff;