Skip to content

Commit

Permalink
ignore debug symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Yang authored and billbo-yang committed May 28, 2024
1 parent 07be449 commit ef94361
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 14 additions & 0 deletions util/fipstools/inject_hash/macho_parser/macho_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,20 @@ int find_macho_symbol_index(uint8_t *symbol_table_data, size_t symbol_table_size
int found = 0;
for (size_t i = 0; i < symbol_table_size / sizeof(struct nlist_64); i++) {
struct nlist_64 *symbol = (struct nlist_64 *)(symbol_table_data + i * sizeof(struct nlist_64));

// Skip debugging symbols
//
// #define N_STAB 0xe0 /* if any of these bits set, a symbolic debugging entry */
//
// "Only symbolic debugging entries have some of the N_STAB bits set and if any of these bits are set then it is
// a symbolic debugging entry (a stab). In which case then the values of the n_type field (the entire field)
// are given in <mach-o/stab.h>"
//
// https://github.com/apple-oss-distributions/xnu/blob/main/EXTERNAL_HEADERS/mach-o/nlist.h
if (symbol->n_type & N_STAB) {
continue;
}

if (strcmp(symbol_name, &string_table[symbol->n_un.n_strx]) == 0) {
if (found == 0) {
*index = symbol->n_value;
Expand Down
1 change: 0 additions & 1 deletion util/fipstools/inject_hash/tests/test_libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ if(FIPS AND APPLE)
set(INJECT_HASH_TEST_LIB_COMPILE_OPTIONS
"-Wno-unused-function"
"-Wno-missing-prototypes"
"-g0"
)

function(create_test_lib name)
Expand Down

0 comments on commit ef94361

Please sign in to comment.