GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
testsuite

Testsuite Extended object-readelf to accept regexes.

The testsuite's object-readelf function now supports regular expressions for more flexible checks of object file metadata.

The object-readelf function in lib/lto.exp was extended to support regular expressions. Previously, it was limited to attribute checks using readelf -A. Now, it accepts a readelf option and a regex, matching the regex against the full readelf output. This allows for more flexible and comprehensive checks of object file metadata in LTO tests, including checks for notes and negative checks to ensure that a regex is not present in the output.

In Details

The object-readelf function in lib/lto.exp is used to verify object file metadata within GCC's LTO testsuite. Previously hardcoded to readelf -A, this commit broadens its utility by allowing testers to specify arbitrary readelf flags and regular expressions. This avoids the need to write separate tests for checking notes or ensuring the absence of specific attributes. The change touches liblto, a part of GCC not generally known outside the LTO team.

For Context

The readelf utility displays information about object files, such as ELF files produced by the compiler. The LTO (Link-Time Optimization) testsuite uses object-readelf to check the metadata of these object files, ensuring that the compiler is producing the correct information. This commit enhances object-readelf with regular expression matching, allowing more complex and flexible checks of object file contents. Testers can now verify specific patterns in the readelf output, expanding the scope and precision of LTO tests.

Filed Under: testsuiteltoreadelfregular expressions