diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4d5346..2df408e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,8 +19,9 @@ jobs: - run: echo "::add-matcher::.github/workflows/gcc_matcher.json" - uses: carlosperate/arm-none-eabi-gcc-action@v1 - run: pip install elf-size-analyze + - run: sudo apt-get update && sudo apt-get install binutils-dev - if: matrix.compiler == 'clang' - run: sudo apt-get update && sudo apt-get install llvm + run: sudo apt-get install llvm - uses: actions/cache@v3 with: path: target/_deps diff --git a/tools/test_linker_plugin.cc b/tools/test_linker_plugin.cc index 7c518f0..d7f9dee 100644 --- a/tools/test_linker_plugin.cc +++ b/tools/test_linker_plugin.cc @@ -15,47 +15,43 @@ // TODO check status -static const struct { - ld_plugin_tag num; - const char* name; -} LD_PLUGIN_TAG_NAMES[] = { - { LDPT_NULL, "LDPT_NULL" }, - { LDPT_NULL, "LDPT_NULL" }, - { LDPT_API_VERSION, "LDPT_API_VERSION" }, - { LDPT_GOLD_VERSION, "LDPT_GOLD_VERSION" }, - { LDPT_LINKER_OUTPUT, "LDPT_LINKER_OUTPUT" }, - { LDPT_OPTION, "LDPT_OPTION" }, - { LDPT_REGISTER_CLAIM_FILE_HOOK, "LDPT_REGISTER_CLAIM_FILE_HOOK" }, - { LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK, "LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK" }, - { LDPT_REGISTER_CLEANUP_HOOK, "LDPT_REGISTER_CLEANUP_HOOK" }, - { LDPT_ADD_SYMBOLS, "LDPT_ADD_SYMBOLS" }, - { LDPT_GET_SYMBOLS, "LDPT_GET_SYMBOLS" }, - { LDPT_ADD_INPUT_FILE, "LDPT_ADD_INPUT_FILE" }, - { LDPT_MESSAGE, "LDPT_MESSAGE" }, - { LDPT_GET_INPUT_FILE, "LDPT_GET_INPUT_FILE" }, - { LDPT_RELEASE_INPUT_FILE, "LDPT_RELEASE_INPUT_FILE" }, - { LDPT_ADD_INPUT_LIBRARY, "LDPT_ADD_INPUT_LIBRARY" }, - { LDPT_OUTPUT_NAME, "LDPT_OUTPUT_NAME" }, - { LDPT_SET_EXTRA_LIBRARY_PATH, "LDPT_SET_EXTRA_LIBRARY_PATH" }, - { LDPT_GNU_LD_VERSION, "LDPT_GNU_LD_VERSION" }, - { LDPT_GET_VIEW, "LDPT_GET_VIEW" }, - { LDPT_GET_INPUT_SECTION_COUNT, "LDPT_GET_INPUT_SECTION_COUNT" }, - { LDPT_GET_INPUT_SECTION_TYPE, "LDPT_GET_INPUT_SECTION_TYPE" }, - { LDPT_GET_INPUT_SECTION_NAME, "LDPT_GET_INPUT_SECTION_NAME" }, - { LDPT_GET_INPUT_SECTION_CONTENTS, "LDPT_GET_INPUT_SECTION_CONTENTS" }, - { LDPT_UPDATE_SECTION_ORDER, "LDPT_UPDATE_SECTION_ORDER" }, - { LDPT_ALLOW_SECTION_ORDERING, "LDPT_ALLOW_SECTION_ORDERING" }, - { LDPT_GET_SYMBOLS_V2, "LDPT_GET_SYMBOLS_V2" }, - { LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS, "LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS" }, - { LDPT_UNIQUE_SEGMENT_FOR_SECTIONS, "LDPT_UNIQUE_SEGMENT_FOR_SECTIONS" }, - { LDPT_GET_SYMBOLS_V3, "LDPT_GET_SYMBOLS_V3" }, - { LDPT_GET_INPUT_SECTION_ALIGNMENT, "LDPT_GET_INPUT_SECTION_ALIGNMENT" }, - { LDPT_GET_INPUT_SECTION_SIZE, "LDPT_GET_INPUT_SECTION_SIZE" }, - { LDPT_REGISTER_NEW_INPUT_HOOK, "LDPT_REGISTER_NEW_INPUT_HOOK" }, - { LDPT_GET_WRAP_SYMBOLS, "LDPT_GET_WRAP_SYMBOLS" }, - { LDPT_ADD_SYMBOLS_V2, "LDPT_ADD_SYMBOLS_V2" }, - { LDPT_GET_API_VERSION, "LDPT_GET_API_VERSION" }, - { LDPT_REGISTER_CLAIM_FILE_HOOK_V2, "LDPT_REGISTER_CLAIM_FILE_HOOK_V2" }, +static const char* const LD_PLUGIN_TAG_NAMES[] = { + "LDPT_NULL", + "LDPT_API_VERSION", + "LDPT_GOLD_VERSION", + "LDPT_LINKER_OUTPUT", + "LDPT_OPTION", + "LDPT_REGISTER_CLAIM_FILE_HOOK", + "LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK", + "LDPT_REGISTER_CLEANUP_HOOK", + "LDPT_ADD_SYMBOLS", + "LDPT_GET_SYMBOLS", + "LDPT_ADD_INPUT_FILE", + "LDPT_MESSAGE", + "LDPT_GET_INPUT_FILE", + "LDPT_RELEASE_INPUT_FILE", + "LDPT_ADD_INPUT_LIBRARY", + "LDPT_OUTPUT_NAME", + "LDPT_SET_EXTRA_LIBRARY_PATH", + "LDPT_GNU_LD_VERSION", + "LDPT_GET_VIEW", + "LDPT_GET_INPUT_SECTION_COUNT", + "LDPT_GET_INPUT_SECTION_TYPE", + "LDPT_GET_INPUT_SECTION_NAME", + "LDPT_GET_INPUT_SECTION_CONTENTS", + "LDPT_UPDATE_SECTION_ORDER", + "LDPT_ALLOW_SECTION_ORDERING", + "LDPT_GET_SYMBOLS_V2", + "LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS", + "LDPT_UNIQUE_SEGMENT_FOR_SECTIONS", + "LDPT_GET_SYMBOLS_V3", + "LDPT_GET_INPUT_SECTION_ALIGNMENT", + "LDPT_GET_INPUT_SECTION_SIZE", + "LDPT_REGISTER_NEW_INPUT_HOOK", + "LDPT_GET_WRAP_SYMBOLS", + "LDPT_ADD_SYMBOLS_V2", + "LDPT_GET_API_VERSION", + "LDPT_REGISTER_CLAIM_FILE_HOOK_V2", }; static struct { @@ -107,19 +103,15 @@ ld_plugin_status onload(ld_plugin_tv* tv) { LOG("hi!"); for (tv = first_tv; tv->tv_tag != 0; tv++) { - for (const auto& tag : LD_PLUGIN_TAG_NAMES) { - if (tag.num == tv->tv_tag) { - switch (tv->tv_tag) { - case LDPT_NULL: - case LDPT_API_VERSION: - case LDPT_GNU_LD_VERSION: - case LDPT_LINKER_OUTPUT: LOG("%s(%d)", tag.name, tv->tv_u.tv_val); break; - case LDPT_OPTION: - case LDPT_OUTPUT_NAME: LOG("%s(%s)", tag.name, tv->tv_u.tv_string); break; - default: LOG("%s(%p)", tag.name, (void*)tv->tv_u.tv_string); break; - } - break; - } + const char* name = LD_PLUGIN_TAG_NAMES[tv->tv_tag]; + switch (tv->tv_tag) { + case LDPT_NULL: + case LDPT_API_VERSION: + case LDPT_GNU_LD_VERSION: + case LDPT_LINKER_OUTPUT: LOG("%s(%d)", name, tv->tv_u.tv_val); break; + case LDPT_OPTION: + case LDPT_OUTPUT_NAME: LOG("%s(%s)", name, tv->tv_u.tv_string); break; + default: LOG("%s(%p)", name, (void*)tv->tv_u.tv_string); break; } }