Skip to content

[lld] select a default eflags for hexagon #108431

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

Merged
merged 1 commit into from
Sep 13, 2024
Merged
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
8 changes: 3 additions & 5 deletions lld/ELF/Arch/Hexagon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,15 @@ Hexagon::Hexagon() {
}

uint32_t Hexagon::calcEFlags() const {
assert(!ctx.objectFiles.empty());

// The architecture revision must always be equal to or greater than
// greatest revision in the list of inputs.
uint32_t ret = 0;
std::optional<uint32_t> ret;
for (InputFile *f : ctx.objectFiles) {
uint32_t eflags = cast<ObjFile<ELF32LE>>(f)->getObj().getHeader().e_flags;
if (eflags > ret)
if (!ret || eflags > *ret)
ret = eflags;
}
return ret;
return ret.value_or(/* Default Arch Rev: */ 0x60);
}

static uint32_t applyMask(uint32_t mask, uint32_t data) {
Expand Down
5 changes: 5 additions & 0 deletions lld/test/ELF/hexagon-eflag.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@
# RUN: llvm-readelf -h %t3 | FileCheck %s
# Verify that the largest arch in the input list is selected.
# CHECK: Flags: 0x62

# RUN: llvm-ar rcsD %t4
# RUN: ld.lld -m hexagonelf %t4 -o %t5
# RUN: llvm-readelf -h %t5 | FileCheck --check-prefix=CHECK-EMPTYARCHIVE %s
# CHECK-EMPTYARCHIVE: Flags: 0x60
Loading