Skip to content

Commit c349d08

Browse files
committed
Add readelf support to run-make-support
1 parent 3baa20b commit c349d08

File tree

1 file changed

+23
-5
lines changed
  • src/tools/run-make-support/src

1 file changed

+23
-5
lines changed

src/tools/run-make-support/src/llvm.rs

+23-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::path::{Path, PathBuf};
22

33
use crate::{env_var, Command};
44

5-
/// Construct a new `llvm-readobj` invocation. This assumes that `llvm-readobj` is available
6-
/// at `$LLVM_BIN_DIR/llvm-readobj`.
5+
/// Construct a new `llvm-readobj` invocation with the `GNU` output style.
6+
/// This assumes that `llvm-readobj` is available at `$LLVM_BIN_DIR/llvm-readobj`.
77
#[track_caller]
88
pub fn llvm_readobj() -> LlvmReadobj {
99
LlvmReadobj::new()
@@ -56,13 +56,24 @@ pub fn llvm_bin_dir() -> PathBuf {
5656
}
5757

5858
impl LlvmReadobj {
59-
/// Construct a new `llvm-readobj` invocation. This assumes that `llvm-readobj` is available
60-
/// at `$LLVM_BIN_DIR/llvm-readobj`.
59+
/// Construct a new `llvm-readobj` invocation with the `GNU` output style.
60+
/// This assumes that `llvm-readobj` is available at `$LLVM_BIN_DIR/llvm-readobj`.
6161
#[track_caller]
6262
pub fn new() -> Self {
6363
let llvm_readobj = llvm_bin_dir().join("llvm-readobj");
6464
let cmd = Command::new(llvm_readobj);
65-
Self { cmd }
65+
let mut readobj = Self { cmd };
66+
readobj.elf_output_style("GNU");
67+
readobj
68+
}
69+
70+
/// Specify the format of the ELF information.
71+
///
72+
/// Valid options are `LLVM` (default), `GNU`, and `JSON`.
73+
pub fn elf_output_style(&mut self, style: &str) -> &mut Self {
74+
self.cmd.arg("--elf-output-style");
75+
self.cmd.arg(style);
76+
self
6677
}
6778

6879
/// Provide an input file.
@@ -76,6 +87,13 @@ impl LlvmReadobj {
7687
self.cmd.arg("--file-header");
7788
self
7889
}
90+
91+
/// Specify the section to display.
92+
pub fn section(&mut self, section: &str) -> &mut Self {
93+
self.cmd.arg("--string-dump");
94+
self.cmd.arg(section);
95+
self
96+
}
7997
}
8098

8199
impl LlvmProfdata {

0 commit comments

Comments
 (0)