[PATCH] D153262: Add named section flag "large" to objcopy
Thomas Köppe via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 19 04:03:16 PDT 2023
tkoeppe created this revision.
Herald added subscribers: pengfei, hiraditya, emaste.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a reviewer: jhenderson.
Herald added a project: All.
tkoeppe requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
Currently, objcopy cannot set the new flag SHF_X86_64_LARGE. This change introduces the named flag "large" which translates to that section flag.
For discussion: should this flag be limited to x86_64 architectures, and if so, how? And where to add tests?
https://reviews.llvm.org/D153262
Files:
include/llvm/ObjCopy/CommonConfig.h
llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===================================================================
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -204,6 +204,7 @@
.CaseLower("contents", SectionFlag::SecContents)
.CaseLower("share", SectionFlag::SecShare)
.CaseLower("exclude", SectionFlag::SecExclude)
+ .CaseLower("large", SectionFlag::SecLarge)
.Default(SectionFlag::SecNone);
}
@@ -217,7 +218,7 @@
errc::invalid_argument,
"unrecognized section flag '%s'. Flags supported for GNU "
"compatibility: alloc, load, noload, readonly, exclude, debug, "
- "code, data, rom, share, contents, merge, strings",
+ "code, data, rom, share, contents, merge, strings, large",
Flag.str().c_str());
ParsedFlags |= ParsedFlag;
}
Index: llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
===================================================================
--- llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
+++ llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
@@ -82,6 +82,8 @@
NewFlags |= ELF::SHF_STRINGS;
if (AllFlags & SectionFlag::SecExclude)
NewFlags |= ELF::SHF_EXCLUDE;
+ if (AllFlags & SectionFlag::SecLarge)
+ NewFlags |= ELF::SHF_X86_64_LARGE;
return NewFlags;
}
Index: include/llvm/ObjCopy/CommonConfig.h
===================================================================
--- include/llvm/ObjCopy/CommonConfig.h
+++ include/llvm/ObjCopy/CommonConfig.h
@@ -69,7 +69,8 @@
SecContents = 1 << 10,
SecShare = 1 << 11,
SecExclude = 1 << 12,
- LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/SecExclude)
+ SecLarge = 1 << 13,
+ LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/SecLarge)
};
struct SectionRename {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153262.532594.patch
Type: text/x-patch
Size: 1767 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230619/1060b93f/attachment.bin>
More information about the llvm-commits
mailing list