@@ -30,7 +30,7 @@ void ConcatOutputSection::addInput(ConcatInputSection *input) {
30
30
flags = input->flags ;
31
31
} else {
32
32
align = std::max (align, input->align );
33
- mergeFlags (input);
33
+ finalizeFlags (input);
34
34
}
35
35
inputs.push_back (input);
36
36
input->parent = this ;
@@ -331,30 +331,29 @@ void ConcatOutputSection::writeTo(uint8_t *buf) const {
331
331
}
332
332
}
333
333
334
- // TODO: this is most likely wrong; reconsider how section flags
335
- // are actually merged. The logic presented here was written without
336
- // any form of informed research.
337
- void ConcatOutputSection::mergeFlags (InputSection *input) {
338
- uint8_t baseType = sectionType (flags);
339
- uint8_t inputType = sectionType (input->flags );
340
- if (baseType != inputType)
341
- error (" Cannot merge section " + input->name + " (type=0x" +
342
- to_hexString (inputType) + " ) into " + name + " (type=0x" +
343
- to_hexString (baseType) + " ): inconsistent types" );
344
-
345
- constexpr uint32_t strictFlags = S_ATTR_DEBUG | S_ATTR_STRIP_STATIC_SYMS |
346
- S_ATTR_NO_DEAD_STRIP | S_ATTR_LIVE_SUPPORT;
347
- if ((input->flags ^ flags) & strictFlags)
348
- error (" Cannot merge section " + input->name + " (flags=0x" +
349
- to_hexString (input->flags ) + " ) into " + name + " (flags=0x" +
350
- to_hexString (flags) + " ): strict flags differ" );
351
-
352
- // Negate pure instruction presence if any section isn't pure.
353
- uint32_t pureMask = ~S_ATTR_PURE_INSTRUCTIONS | (input->flags & flags);
354
-
355
- // Merge the rest
356
- flags |= input->flags ;
357
- flags &= pureMask;
334
+ void ConcatOutputSection::finalizeFlags (InputSection *input) {
335
+ uint8_t inputType = input->flags & SECTION_TYPE;
336
+ switch (inputType) {
337
+ default /* type-unspec'ed*/ :
338
+ // FIXME: Add additional logics here when supporting emitting obj files.
339
+ break ;
340
+ case S_4BYTE_LITERALS:
341
+ case S_8BYTE_LITERALS:
342
+ case S_16BYTE_LITERALS:
343
+ case S_CSTRING_LITERALS:
344
+ case S_ZEROFILL:
345
+ case S_LAZY_SYMBOL_POINTERS:
346
+ case S_MOD_TERM_FUNC_POINTERS:
347
+ case S_THREAD_LOCAL_REGULAR:
348
+ case S_THREAD_LOCAL_ZEROFILL:
349
+ case S_THREAD_LOCAL_VARIABLES:
350
+ case S_THREAD_LOCAL_INIT_FUNCTION_POINTERS:
351
+ case S_THREAD_LOCAL_VARIABLE_POINTERS:
352
+ case S_NON_LAZY_SYMBOL_POINTERS:
353
+ case S_SYMBOL_STUBS:
354
+ flags |= input->flags ;
355
+ break ;
356
+ }
358
357
}
359
358
360
359
void ConcatOutputSection::eraseOmittedInputSections () {
0 commit comments