Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Jan 11, 2025
1 parent cf0d750 commit 48077dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 3 additions & 5 deletions src/output-chunks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2661,10 +2661,8 @@ void VerdefSection<E>::construct(Context<E> &ctx) {
};

std::string_view soname = ctx.arg.soname;
if (soname.empty()) {
std::filesystem::path path(ctx.arg.output);
soname = save_string(ctx, path.filename().string());
}
if (soname.empty())
soname = save_string(ctx, path_filename(ctx.arg.output));
write(soname, 1, VER_FLG_BASE);

i64 idx = VER_NDX_LAST_RESERVED + 1;
Expand Down Expand Up @@ -2965,7 +2963,7 @@ void ComdatGroupSection<E>::copy_buf(Context<E> &ctx) {

template <typename E>
void GnuDebuglinkSection<E>::update_shdr(Context<E> &ctx) {
filename = std::filesystem::path(ctx.arg.separate_debug_file).filename().string();
filename = path_filename(ctx.arg.separate_debug_file);
this->shdr.sh_size = align_to(filename.size() + 1, 4) + 4;
}

Expand Down
20 changes: 11 additions & 9 deletions src/passes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ void apply_exclude_libs(Context<E> &ctx) {
std::unordered_set<std::string_view> set(ctx.arg.exclude_libs.begin(),
ctx.arg.exclude_libs.end());

for (ObjectFile<E> *file : ctx.objs)
if (!file->archive_name.empty())
if (set.contains(path_filename(file->archive_name)) || set.contains("ALL"))
file->exclude_libs = true;
if (!set.empty())
for (ObjectFile<E> *file : ctx.objs)
if (!file->archive_name.empty())
if (set.contains(path_filename(file->archive_name)) || set.contains("ALL"))
file->exclude_libs = true;
}

template <typename E>
Expand Down Expand Up @@ -863,11 +864,12 @@ void add_synthetic_symbols(Context<E> &ctx) {

template <typename E>
void apply_section_align(Context<E> &ctx) {
for (Chunk<E> *chunk : ctx.chunks)
if (OutputSection<E> *osec = chunk->to_osec())
if (auto it = ctx.arg.section_align.find(osec->name);
it != ctx.arg.section_align.end())
osec->shdr.sh_addralign = it->second;
std::unordered_map<std::string_view, u64> &map = ctx.arg.section_align;
if (!map.empty())
for (Chunk<E> *chunk : ctx.chunks)
if (OutputSection<E> *osec = chunk->to_osec())
if (auto it = map.find(osec->name); it != map.end())
osec->shdr.sh_addralign = it->second;
}

template <typename E>
Expand Down

0 comments on commit 48077dd

Please sign in to comment.