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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

markj created this revision.May 30 2019, 5:04 PM
arrowd added a subscriber: arrowd.Jun 1 2019, 7:57 PM
markj updated this revision to Diff 58202.Jun 3 2019, 7:43 PM

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

emaste added a comment.Jun 4 2019, 3:53 PM

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.

markj added a comment.Jun 4 2019, 4:06 PM

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.

markj added a comment.Jun 4 2019, 4:07 PM

qsort() the entries by reverse alphabetical order

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

emaste accepted this revision.Jun 4 2019, 6:17 PM
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.