@@ -2,8 +2,8 @@ use std::path::{Path, PathBuf};
22
33use 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`.
77pub fn llvm_readobj ( ) -> LlvmReadobj {
88 LlvmReadobj :: new ( )
99}
@@ -53,12 +53,23 @@ pub fn llvm_bin_dir() -> PathBuf {
5353}
5454
5555impl LlvmReadobj {
56- /// Construct a new `llvm-readobj` invocation. This assumes that `llvm-readobj` is available
57- /// at `$LLVM_BIN_DIR/llvm-readobj`.
56+ /// Construct a new `llvm-readobj` invocation with the `GNU` output style.
57+ /// This assumes that `llvm-readobj` is available at `$LLVM_BIN_DIR/llvm-readobj`.
5858 pub fn new ( ) -> Self {
5959 let llvm_readobj = llvm_bin_dir ( ) . join ( "llvm-readobj" ) ;
6060 let cmd = Command :: new ( llvm_readobj) ;
61- Self { cmd }
61+ let mut readobj = Self { cmd } ;
62+ readobj. elf_output_style ( "GNU" ) ;
63+ readobj
64+ }
65+
66+ /// Specify the format of the ELF information.
67+ ///
68+ /// Valid options are `LLVM` (default), `GNU`, and `JSON`.
69+ pub fn elf_output_style ( & mut self , style : & str ) -> & mut Self {
70+ self . cmd . arg ( "--elf-output-style" ) ;
71+ self . cmd . arg ( style) ;
72+ self
6273 }
6374
6475 /// Provide an input file.
@@ -72,6 +83,13 @@ impl LlvmReadobj {
7283 self . cmd . arg ( "--file-header" ) ;
7384 self
7485 }
86+
87+ /// Specify the section to display.
88+ pub fn section ( & mut self , section : & str ) -> & mut Self {
89+ self . cmd . arg ( "--string-dump" ) ;
90+ self . cmd . arg ( section) ;
91+ self
92+ }
7593}
7694
7795impl LlvmProfdata {
0 commit comments