Skip to content

Commit

Permalink
fix compilation of the linker script with the CI-provided binutils
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitmel committed Dec 20, 2023
1 parent 58d71da commit 1358e22
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 55 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
100 changes: 46 additions & 54 deletions tools/test_linker_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 1358e22

Please sign in to comment.