1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-13 09:39:13 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-11-04 10:43:05 +09:00
parent d6d6225046
commit 57fa2e0e61
3 changed files with 23 additions and 7 deletions

13
main.cc
View File

@ -765,6 +765,19 @@ int main(int argc, char **argv) {
break;
}
}
// __start_ and __stop_ symbols
for (OutputChunk *chunk : output_chunks) {
if (!is_c_identifier(chunk->name))
continue;
Symbol *start = Symbol::intern(("__start_" + chunk->name).str());
start->input_section = chunk->sections[0];
Symbol *stop = Symbol::intern(("__stop_" + chunk->name).str());
stop->input_section = chunk->sections[0];
stop->addr = chunk->shdr.sh_size;
}
}
// Fix regular symbol addresses.

2
mold.h
View File

@ -427,6 +427,8 @@ public:
}
};
bool is_c_identifier(StringRef name);
namespace out {
extern OutputEhdr *ehdr;
extern OutputShdr *shdr;

View File

@ -419,7 +419,7 @@ bool ObjectFile::is_in_archive() {
return !archive_name.empty();
}
static bool is_c_identifier(StringRef name) {
bool is_c_identifier(StringRef name) {
if (name == "")
return false;
if (!isalpha(name[0]) && name[0] != '_')
@ -470,12 +470,13 @@ ObjectFile *ObjectFile::create_internal_file(ArrayRef<OutputChunk *> output_chun
out::__preinit_array_end = add("__preinit_array_end", STB_LOCAL);
for (OutputChunk *chunk : output_chunks) {
if (is_c_identifier(chunk->name)) {
auto *start = new std::string(("__start_" + chunk->name).str());
auto *stop = new std::string(("__stop_" + chunk->name).str());
add(*start, STB_GLOBAL);
add(*stop, STB_GLOBAL);
}
if (!is_c_identifier(chunk->name))
continue;
auto *start = new std::string(("__start_" + chunk->name).str());
auto *stop = new std::string(("__stop_" + chunk->name).str());
add(*start, STB_GLOBAL);
add(*stop, STB_GLOBAL);
}
obj->elf_syms = *elf_syms;