We have a difference in behavior with bfd linkers.
bfd default script looks like:
.init_array : { ... KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) ... }
SORT_BY_INIT_PRIORITY is a feature that allows sorting by priority and used for
placing to .init_array and .fini_array sections.
Currently LLD implements SORT_BY_INIT_PRIORITY behavior that is similar for both types of sections,
that is looks wrong. And it is inconsistent with how gnu linkers work here.
That change is mostly for overall correctness,
because .ctors/.dtors is very outdated feature. Though somebody may still use such kind of bfd
script for example and will have a bug.
trim() trims the character both from both ends. That's probably not what you want.