Skip to content

[BPF] fix print_btf.py test script on bigendian machines #110332

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 29, 2024
Merged
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: 4 additions & 4 deletions llvm/test/CodeGen/BPF/BTF/print_btf.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def print_btf(filename):
buf = file.read()

fmt_cache = {}
endian_pfx = ""
endian_pfx = ">" # big endian
off = 0

def unpack(fmt):
Expand All @@ -104,9 +104,9 @@ def unpack(fmt):
# Use magic number at the header start to determine endianness
(magic,) = unpack("H")
if magic == 0xEB9F:
endian_pfx = "<"
endian_pfx = ">" # big endian
elif magic == 0x9FEB:
endian_pfx = ">"
endian_pfx = "<" # little endian
else:
warn(f"Unexpected BTF magic: {magic:02x}")
return
Expand Down Expand Up @@ -290,6 +290,6 @@ def warn_nonzero(val, name):

if __name__ == "__main__":
if len(sys.argv) != 2:
warn("Usage: {sys.argv[0]} <btf_file>")
warn(f"Usage: {sys.argv[0]} <btf_file>")
sys.exit(1)
print_btf(sys.argv[1])
Loading