@@ -60,6 +60,18 @@ pub fn llvm_pdbutil() -> LlvmPdbutil {
6060 LlvmPdbutil :: new ( )
6161}
6262
63+ /// Construct a new `llvm-dis` invocation. This assumes that `llvm-dis` is available
64+ /// at `$LLVM_BIN_DIR/llvm-dis`.
65+ pub fn llvm_dis ( ) -> LlvmDis {
66+ LlvmDis :: new ( )
67+ }
68+
69+ /// Construct a new `llvm-objcopy` invocation. This assumes that `llvm-objcopy` is available
70+ /// at `$LLVM_BIN_DIR/llvm-objcopy`.
71+ pub fn llvm_objcopy ( ) -> LlvmObjcopy {
72+ LlvmObjcopy :: new ( )
73+ }
74+
6375/// A `llvm-readobj` invocation builder.
6476#[ derive( Debug ) ]
6577#[ must_use]
@@ -123,6 +135,20 @@ pub struct LlvmPdbutil {
123135 cmd : Command ,
124136}
125137
138+ /// A `llvm-dis` invocation builder.
139+ #[ derive( Debug ) ]
140+ #[ must_use]
141+ pub struct LlvmDis {
142+ cmd : Command ,
143+ }
144+
145+ /// A `llvm-objcopy` invocation builder.
146+ #[ derive( Debug ) ]
147+ #[ must_use]
148+ pub struct LlvmObjcopy {
149+ cmd : Command ,
150+ }
151+
126152crate :: macros:: impl_common_helpers!( LlvmReadobj ) ;
127153crate :: macros:: impl_common_helpers!( LlvmProfdata ) ;
128154crate :: macros:: impl_common_helpers!( LlvmFilecheck ) ;
@@ -132,6 +158,8 @@ crate::macros::impl_common_helpers!(LlvmNm);
132158crate :: macros:: impl_common_helpers!( LlvmBcanalyzer ) ;
133159crate :: macros:: impl_common_helpers!( LlvmDwarfdump ) ;
134160crate :: macros:: impl_common_helpers!( LlvmPdbutil ) ;
161+ crate :: macros:: impl_common_helpers!( LlvmDis ) ;
162+ crate :: macros:: impl_common_helpers!( LlvmObjcopy ) ;
135163
136164/// Generate the path to the bin directory of LLVM.
137165#[ must_use]
@@ -390,3 +418,41 @@ impl LlvmPdbutil {
390418 self
391419 }
392420}
421+
422+ impl LlvmObjcopy {
423+ /// Construct a new `llvm-objcopy` invocation. This assumes that `llvm-objcopy` is available
424+ /// at `$LLVM_BIN_DIR/llvm-objcopy`.
425+ pub fn new ( ) -> Self {
426+ let llvm_objcopy = llvm_bin_dir ( ) . join ( "llvm-objcopy" ) ;
427+ let cmd = Command :: new ( llvm_objcopy) ;
428+ Self { cmd }
429+ }
430+
431+ /// Dump the contents of `section` into the file at `path`.
432+ #[ track_caller]
433+ pub fn dump_section < S : AsRef < str > , P : AsRef < Path > > (
434+ & mut self ,
435+ section_name : S ,
436+ path : P ,
437+ ) -> & mut Self {
438+ self . cmd . arg ( "--dump-section" ) ;
439+ self . cmd . arg ( format ! ( "{}={}" , section_name. as_ref( ) , path. as_ref( ) . to_str( ) . unwrap( ) ) ) ;
440+ self
441+ }
442+ }
443+
444+ impl LlvmDis {
445+ /// Construct a new `llvm-dis` invocation. This assumes that `llvm-dis` is available
446+ /// at `$LLVM_BIN_DIR/llvm-dis`.
447+ pub fn new ( ) -> Self {
448+ let llvm_dis = llvm_bin_dir ( ) . join ( "llvm-dis" ) ;
449+ let cmd = Command :: new ( llvm_dis) ;
450+ Self { cmd }
451+ }
452+
453+ /// Provide an input file.
454+ pub fn input < P : AsRef < Path > > ( & mut self , path : P ) -> & mut Self {
455+ self . cmd . arg ( path. as_ref ( ) ) ;
456+ self
457+ }
458+ }
0 commit comments