aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Jackson <snortotter@gmail.com>2019-08-15 09:45:09 +0000
committerChris Jackson <snortotter@gmail.com>2019-08-15 09:45:09 +0000
commite5cdfbc65cac49fedba6cb3def55d62d851796ab (patch)
tree3913ce5c65df5dc0ca153852bfbe5e51a7f2f0c3
parent04f2f32869b3a62e236cfaa134f378771e48c129 (diff)
downloadllvm-e5cdfbc65cac49fedba6cb3def55d62d851796ab.zip
llvm-e5cdfbc65cac49fedba6cb3def55d62d851796ab.tar.gz
llvm-e5cdfbc65cac49fedba6cb3def55d62d851796ab.tar.bz2
[llvm-objcopy] Allow 'protected' visibility to be set when using
add-symbol Reviewers: Maskray, rupprecht Differential Revision: https://reviews.llvm.org/D65891 llvm-svn: 368982
-rw-r--r--llvm/docs/CommandGuide/llvm-objcopy.rst1
-rw-r--r--llvm/test/tools/llvm-objcopy/ELF/add-symbol.test12
-rw-r--r--llvm/tools/llvm-objcopy/CopyConfig.cpp1
-rw-r--r--llvm/tools/llvm-objcopy/ObjcopyOpts.td2
4 files changed, 10 insertions, 6 deletions
diff --git a/llvm/docs/CommandGuide/llvm-objcopy.rst b/llvm/docs/CommandGuide/llvm-objcopy.rst
index 64ba094..044293c 100644
--- a/llvm/docs/CommandGuide/llvm-objcopy.rst
+++ b/llvm/docs/CommandGuide/llvm-objcopy.rst
@@ -160,6 +160,7 @@ them.
- `weak` = the symbol will have weak binding.
- `default` = the symbol will have default visibility.
- `hidden` = the symbol will have hidden visibility.
+ - `protected` = the symbol will have protected visibility.
- `file` = the symbol will be an `STT_FILE` symbol.
- `section` = the symbol will be an `STT_SECTION` symbol.
- `object` = the symbol will be an `STT_OBJECT` symbol.
diff --git a/llvm/test/tools/llvm-objcopy/ELF/add-symbol.test b/llvm/test/tools/llvm-objcopy/ELF/add-symbol.test
index bf75b4f..fd838602 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/add-symbol.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/add-symbol.test
@@ -2,6 +2,7 @@
# RUN: llvm-objcopy --add-symbol='abs1=1' \
# RUN: --add-symbol='abs2=2,LoCaL,HiDdEn,FuNcTiOn' \
# RUN: --add-symbol='abs3=3,global,default,object' \
+# RUN: --add-symbol='abs4=4,global,protected,object' \
# RUN: --add-symbol='foo.cpp=0,file' \
# RUN: --add-symbol='=.text:0,section' \
# RUN: --add-symbol='data=.data:0x100,weak' \
@@ -58,14 +59,15 @@ ProgramHeaders:
Sections:
- Section: .data
-# CHECK: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
+# CHECK: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
# CHECK-NEXT: 1: 00000001 0 NOTYPE GLOBAL DEFAULT ABS abs1
# CHECK-NEXT: 2: 00000002 0 FUNC LOCAL HIDDEN ABS abs2
# CHECK-NEXT: 3: 00000003 0 OBJECT GLOBAL DEFAULT ABS abs3
-# CHECK-NEXT: 4: 00000000 0 FILE GLOBAL DEFAULT ABS foo.cpp
-# CHECK-NEXT: 5: 00001000 0 SECTION GLOBAL DEFAULT 1
-# CHECK-NEXT: 6: 00002100 0 NOTYPE WEAK DEFAULT 2 data
-# CHECK-NEXT: 7: 00001000 0 IFUNC GLOBAL DEFAULT 1 ifunc
+# CHECK-NEXT: 4: 00000004 0 OBJECT GLOBAL PROTECTED ABS abs4
+# CHECK-NEXT: 5: 00000000 0 FILE GLOBAL DEFAULT ABS foo.cpp
+# CHECK-NEXT: 6: 00001000 0 SECTION GLOBAL DEFAULT 1
+# CHECK-NEXT: 7: 00002100 0 NOTYPE WEAK DEFAULT 2 data
+# CHECK-NEXT: 8: 00001000 0 IFUNC GLOBAL DEFAULT 1 ifunc
# IGNORED: 1: 00000000 0 NOTYPE GLOBAL DEFAULT ABS dummy1
# IGNORED-NEXT: 2: 00000000 0 NOTYPE GLOBAL DEFAULT ABS dummy2
diff --git a/llvm/tools/llvm-objcopy/CopyConfig.cpp b/llvm/tools/llvm-objcopy/CopyConfig.cpp
index 3cd9566..67ba38b 100644
--- a/llvm/tools/llvm-objcopy/CopyConfig.cpp
+++ b/llvm/tools/llvm-objcopy/CopyConfig.cpp
@@ -232,6 +232,7 @@ static Expected<NewSymbolInfo> parseNewSymbolInfo(StringRef FlagValue) {
.CaseLower("weak", [&SI] { SI.Bind = ELF::STB_WEAK; })
.CaseLower("default", [&SI] { SI.Visibility = ELF::STV_DEFAULT; })
.CaseLower("hidden", [&SI] { SI.Visibility = ELF::STV_HIDDEN; })
+ .CaseLower("protected", [&SI] { SI.Visibility = ELF::STV_PROTECTED; })
.CaseLower("file", [&SI] { SI.Type = ELF::STT_FILE; })
.CaseLower("section", [&SI] { SI.Type = ELF::STT_SECTION; })
.CaseLower("object", [&SI] { SI.Type = ELF::STT_OBJECT; })
diff --git a/llvm/tools/llvm-objcopy/ObjcopyOpts.td b/llvm/tools/llvm-objcopy/ObjcopyOpts.td
index 20e9851..94a4dc8 100644
--- a/llvm/tools/llvm-objcopy/ObjcopyOpts.td
+++ b/llvm/tools/llvm-objcopy/ObjcopyOpts.td
@@ -214,7 +214,7 @@ def adjust_start : JoinedOrSeparate<["--"], "adjust-start">,
defm add_symbol
: Eq<"add-symbol", "Add new symbol <name> to .symtab. Accepted flags: "
- "global, local, weak, default, hidden, file, section, object, "
+ "global, local, weak, default, hidden, protected, file, section, object, "
"function, indirect-function. Accepted but ignored for "
"compatibility: debug, constructor, warning, indirect, synthetic, "
"unique-object, before.">,