@@ -576,15 +576,14 @@ get_output_section_key(Context<E> &ctx, InputSection<E> &isec,
576576 // We do not place them into .init_array/.fini_array because such
577577 // invalid pointer values would simply make the program to crash.
578578 if (ctors_in_init_array && !isec.get_rels (ctx).empty ()) {
579- std::string_view name = isec.name ();
580- if (name == " .ctors" || name.starts_with (" .ctors." ))
579+ if (isec.name == " .ctors" || isec.name .starts_with (" .ctors." ))
581580 return {" .init_array" , SHT_INIT_ARRAY};
582- if (name == " .dtors" || name.starts_with (" .dtors." ))
581+ if (isec. name == " .dtors" || isec. name .starts_with (" .dtors." ))
583582 return {" .fini_array" , SHT_FINI_ARRAY};
584583 }
585584
586585 const ElfShdr<E> &shdr = isec.shdr ();
587- std::string_view name = get_output_name (ctx, isec.name () , shdr.sh_flags );
586+ std::string_view name = get_output_name (ctx, isec.name , shdr.sh_flags );
588587 u64 type = canonicalize_type<E>(name, shdr.sh_type );
589588 return {name, type};
590589}
@@ -645,7 +644,7 @@ void create_output_sections(Context<E> &ctx) {
645644 ~SHF_COMPRESSED & ~SHF_GNU_RETAIN;
646645
647646 if (ctx.arg .relocatable && (sh_flags & SHF_GROUP)) {
648- OutputSection<E> *osec = new OutputSection<E>(isec->name () , shdr.sh_type );
647+ OutputSection<E> *osec = new OutputSection<E>(isec->name , shdr.sh_type );
649648 osec->sh_flags = sh_flags;
650649 isec->output_section = osec;
651650 ctx.osec_pool .emplace_back (osec);
@@ -1298,7 +1297,7 @@ void check_symbol_types(Context<E> &ctx) {
12981297template <typename E>
12991298static i64 get_init_fini_priority (InputSection<E> *isec) {
13001299 static std::regex re (R"( \.(\d+)$)" , std::regex_constants::optimize);
1301- std::string_view name = isec->name () ;
1300+ std::string_view name = isec->name ;
13021301 std::cmatch m;
13031302 if (std::regex_search (name.data (), name.data () + name.size (), m, re))
13041303 return std::stoi (m[1 ]);
@@ -1315,14 +1314,14 @@ static i64 get_ctor_dtor_priority(InputSection<E> *isec) {
13151314 // crtbegin.o and crtend.o contain marker symbols such as
13161315 // __CTOR_LIST__ or __DTOR_LIST__. So they have to be at the
13171316 // beginning or end of the section.
1318- std::smatch m;
1319- if (std::regex_search (isec->file .filename , m, re1))
1317+ if (std::regex_search (isec->file .filename , re1))
13201318 return -2 ;
1321- if (std::regex_search (isec->file .filename , m, re2))
1319+ if (std::regex_search (isec->file .filename , re2))
13221320 return 65536 ;
13231321
1324- std::string name (isec->name ());
1325- if (std::regex_search (name, m, re3))
1322+ std::string_view name = isec->name ;
1323+ std::cmatch m;
1324+ if (std::regex_search (name.data (), name.data () + name.size (), m, re3))
13261325 return std::stoi (m[1 ]);
13271326 return -1 ;
13281327}
@@ -1346,8 +1345,8 @@ void sort_init_fini(Context<E> &ctx) {
13461345 std::vector<Entry> vec;
13471346
13481347 for (InputSection<E> *isec : osec->members ) {
1349- std::string_view name = isec->name ();
1350- if (name. starts_with ( " .ctors " ) || name.starts_with (" .dtors" ))
1348+ if ( isec->name . starts_with ( " .ctors " ) ||
1349+ isec-> name .starts_with (" .dtors" ))
13511350 vec.push_back ({isec, 65535 - get_ctor_dtor_priority (isec)});
13521351 else
13531352 vec.push_back ({isec, get_init_fini_priority (isec)});
@@ -1555,13 +1554,13 @@ void fixup_ctors_in_init_array(Context<E> &ctx) {
15551554 if (Chunk<E> *chunk = find_chunk (ctx, " .init_array" ))
15561555 if (OutputSection<E> *osec = chunk->to_osec ())
15571556 for (InputSection<E> *isec : osec->members )
1558- if (isec->name () .starts_with (" .ctors" ))
1557+ if (isec->name .starts_with (" .ctors" ))
15591558 reverse_contents (*isec);
15601559
15611560 if (Chunk<E> *chunk = find_chunk (ctx, " .fini_array" ))
15621561 if (OutputSection<E> *osec = chunk->to_osec ())
15631562 for (InputSection<E> *isec : osec->members )
1564- if (isec->name () .starts_with (" .dtors" ))
1563+ if (isec->name .starts_with (" .dtors" ))
15651564 reverse_contents (*isec);
15661565}
15671566
0 commit comments