Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable building with lld #75

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions libsel4test/include/sel4test/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,17 @@ typedef struct test_type {
test_result_t (*run_test)(struct testcase *test, uintptr_t e);
} ALIGN(32) test_type_t;

#if defined(__has_attribute) && __has_attribute(retain)
heshamelmatary marked this conversation as resolved.
Show resolved Hide resolved
#define ATTR_USED_RETAIN __attribute__((used,retain))
#else
#define ATTR_USED_RETAIN __attribute__((used))
#endif

/* Declare a test type.
* For now, we put the test types in a separate elf section. */
#define DEFINE_TEST_TYPE(_name, _id, _set_up_test_type, _tear_down_test_type, _set_up, _tear_down, _run_test) \
__attribute__((used)) __attribute__((section("_test_type"))) struct test_type TEST_TYPE_ ##_name = { \
ATTR_USED_RETAIN __attribute__((section("_test_type"))) \
struct test_type TEST_TYPE_ ##_name = { \
.name = #_name, \
.id = _id, \
.set_up_test_type = _set_up_test_type, \
Expand Down Expand Up @@ -134,7 +141,8 @@ typedef struct testcase ALIGN(sizeof(struct testcase)) testcase_t;
* that it is accepted by C++ compilers.
*/
#define DEFINE_TEST_WITH_TYPE(_name, _description, _function, _test_type, _enabled) \
__attribute__((used)) __attribute__((section("_test_case"))) struct testcase TEST_ ## _name = { \
ATTR_USED_RETAIN __attribute__((section("_test_case"))) \
struct testcase TEST_ ## _name = { \
#_name, \
_description, \
(test_fn)_function, \
Expand Down
15 changes: 15 additions & 0 deletions libsel4utils/src/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,21 @@ int sel4utils_configure_process_custom(sel4utils_process_t *process, vka_t *vka,
goto error;
}
sel4utils_elf_read_phdrs(&elf, process->num_elf_phdrs, process->elf_phdrs);

/* If PT_PHDR exists in the program headers, assign PT_NULL to it.
* This is because muslc libc searches for PT_PHDR and if found,
* it assumes it's part of the ELF image and relocates the entire
* subsequent program header segments according to PT_PHDR's base. This is
* wrong and will trigger mapping errors.
*/
Elf_Phdr *phdr = process->elf_phdrs;

for (int i = 0; i < process->num_elf_phdrs; i++, phdr++) {
if (phdr->p_type == PT_PHDR) {
phdr->p_type = PT_NULL;
}
}

} else {
process->entry_point = config.entry_point;
process->sysinfo = config.sysinfo;
Expand Down
Loading