Page MenuHomeFreeBSD

strip: Use libelftc_string_table to manage the section string table.
ClosedPublic

Authored by markj on May 30 2019, 5:04 PM.

Details

Summary

This replaces some hand-rolled routines. libelftc uses a hash table to
speed up lookups, so this ends up being way faster.

The previous implementation does suffix matching, which libelftc does
not. However, I think this is fine; in general it is unlikely that one
section's name is a suffix of another. For .strtab we'd want to do
suffix matching.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Destroy the section string table before destroying the corresponding
ELF section descriptor.

The previous implementation does suffix matching, which libelftc does not. However, I think this is fine; in general it is unlikely that one section's name is a suffix of another. For .strtab we'd want to do suffix matching.

I agree this is probably fine - suffix matching can come into play with -ffunction-sections but in that case it's an entry in strtab that's a suffix of the section name.

The previous implementation does suffix matching, which libelftc does not. However, I think this is fine; in general it is unlikely that one section's name is a suffix of another. For .strtab we'd want to do suffix matching.

I agree this is probably fine - suffix matching can come into play with -ffunction-sections but in that case it's an entry in strtab that's a suffix of the section name.

It also would not be too hard to add it to libelftc_string_table, especially since we are allowed to break the API. Before finalizing the string table image, qsort() the entries by reverse alphabetical order and do matching on adjacent entries.

qsort() the entries by reverse alphabetical order

I mean, sort by treating the end of the string as most significant instead of least significant.

This revision is now accepted and ready to land.Jun 4 2019, 6:17 PM
This revision was automatically updated to reflect the committed changes.