@@ -8,7 +8,7 @@ use std::path::Path;
88use object:: write:: { self , StandardSegment , Symbol , SymbolSection } ;
99use object:: {
1010 elf, pe, xcoff, Architecture , BinaryFormat , Endianness , FileFlags , Object , ObjectSection ,
11- ObjectSymbol , SectionFlags , SectionKind , SymbolFlags , SymbolKind , SymbolScope ,
11+ ObjectSymbol , SectionFlags , SectionKind , SubArchitecture , SymbolFlags , SymbolKind , SymbolScope ,
1212} ;
1313
1414use rustc_data_structures:: memmap:: Mmap ;
@@ -182,37 +182,40 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
182182 Endian :: Little => Endianness :: Little ,
183183 Endian :: Big => Endianness :: Big ,
184184 } ;
185- let architecture = match & sess. target . arch [ ..] {
186- "arm" => Architecture :: Arm ,
187- "aarch64" => {
185+ let ( architecture, sub_architecture ) = match & sess. target . arch [ ..] {
186+ "arm" => ( Architecture :: Arm , None ) ,
187+ "aarch64" => (
188188 if sess. target . pointer_width == 32 {
189189 Architecture :: Aarch64_Ilp32
190190 } else {
191191 Architecture :: Aarch64
192- }
193- }
194- "x86" => Architecture :: I386 ,
195- "s390x" => Architecture :: S390x ,
196- "mips" | "mips32r6" => Architecture :: Mips ,
197- "mips64" | "mips64r6" => Architecture :: Mips64 ,
198- "x86_64" => {
192+ } ,
193+ None ,
194+ ) ,
195+ "x86" => ( Architecture :: I386 , None ) ,
196+ "s390x" => ( Architecture :: S390x , None ) ,
197+ "mips" | "mips32r6" => ( Architecture :: Mips , None ) ,
198+ "mips64" | "mips64r6" => ( Architecture :: Mips64 , None ) ,
199+ "x86_64" => (
199200 if sess. target . pointer_width == 32 {
200201 Architecture :: X86_64_X32
201202 } else {
202203 Architecture :: X86_64
203- }
204- }
205- "powerpc" => Architecture :: PowerPc ,
206- "powerpc64" => Architecture :: PowerPc64 ,
207- "riscv32" => Architecture :: Riscv32 ,
208- "riscv64" => Architecture :: Riscv64 ,
209- "sparc64" => Architecture :: Sparc64 ,
210- "avr" => Architecture :: Avr ,
211- "msp430" => Architecture :: Msp430 ,
212- "hexagon" => Architecture :: Hexagon ,
213- "bpf" => Architecture :: Bpf ,
214- "loongarch64" => Architecture :: LoongArch64 ,
215- "csky" => Architecture :: Csky ,
204+ } ,
205+ None ,
206+ ) ,
207+ "powerpc" => ( Architecture :: PowerPc , None ) ,
208+ "powerpc64" => ( Architecture :: PowerPc64 , None ) ,
209+ "riscv32" => ( Architecture :: Riscv32 , None ) ,
210+ "riscv64" => ( Architecture :: Riscv64 , None ) ,
211+ "sparc64" => ( Architecture :: Sparc64 , None ) ,
212+ "avr" => ( Architecture :: Avr , None ) ,
213+ "msp430" => ( Architecture :: Msp430 , None ) ,
214+ "hexagon" => ( Architecture :: Hexagon , None ) ,
215+ "bpf" => ( Architecture :: Bpf , None ) ,
216+ "loongarch64" => ( Architecture :: LoongArch64 , None ) ,
217+ "csky" => ( Architecture :: Csky , None ) ,
218+ "arm64ec" => ( Architecture :: Aarch64 , Some ( SubArchitecture :: Arm64EC ) ) ,
216219 // Unsupported architecture.
217220 _ => return None ,
218221 } ;
@@ -227,6 +230,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
227230 } ;
228231
229232 let mut file = write:: Object :: new ( binary_format, architecture, endianness) ;
233+ file. set_sub_architecture ( sub_architecture) ;
230234 if sess. target . is_like_osx {
231235 if macho_is_arm64e ( & sess. target ) {
232236 file. set_macho_cpu_subtype ( object:: macho:: CPU_SUBTYPE_ARM64E ) ;
0 commit comments