On Jun 19, 2014, at 11:58 AM, e...@ragequ.it wrote:
> Hey guys,
>
> I’m having some issues building OVMF on OS X 10.9 with the latest dev tools.
> I’m running Xcode 5.1.1, with the “Late June” Command Line Tools.
>
> $ clang --version
> Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
> Target: x86_64-apple-darwin13.0.0
> Thread model: posix
>
> Issue #1
>
> $ build -p OvmfPkg/OvmfPkgX64.dsc
> <snip>
> Building ...
> /Users/x/code/ext/edk2/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
> [X64]
> "clang" -E -x assembler-with-cpp -include
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib/DEBUG/AutoGen.h
> -I/Users/x/code/ext/edk2/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64
> -I/Users/x/code/ext/edk2/UefiCpuPkg/Library/CpuExceptionHandlerLib
> -I/Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib/DEBUG
> -I/Users/x/code/ext/edk2/MdePkg -I/Users/x/code/ext/edk2/MdePkg/Include
> -I/Users/x/code/ext/edk2/MdePkg/Include/X64
> -I/Users/x/code/ext/edk2/MdeModulePkg
> -I/Users/x/code/ext/edk2/MdeModulePkg/Include
> -I/Users/x/code/ext/edk2/UefiCpuPkg
> -I/Users/x/code/ext/edk2/UefiCpuPkg/Include
> /Users/x/code/ext/edk2/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.S
> >
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib/OUTPUT/X64/ExceptionHandlerAsm.i
> Trim --trim-long --source-code -o
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib/OUTPUT/X64/ExceptionHandlerAsm.iii
>
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib/OUTPUT/X64/ExceptionHandlerAsm.i
> "as" -arch x86_64 -g -o
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib/OUTPUT/X64/ExceptionHandlerAsm.obj
> -I/Users/x/code/ext/edk2/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64
> -I/Users/x/code/ext/edk2/UefiCpuPkg/Library/CpuExceptionHandlerLib
> -I/Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib/DEBUG
> -I/Users/x/code/ext/edk2/MdePkg -I/Users/x/code/ext/edk2/MdePkg/Include
> -I/Users/x/code/ext/edk2/MdePkg/Include/X64
> -I/Users/x/code/ext/edk2/MdeModulePkg
> -I/Users/x/code/ext/edk2/MdeModulePkg/Include
> -I/Users/x/code/ext/edk2/UefiCpuPkg
> -I/Users/x/code/ext/edk2/UefiCpuPkg/Include
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib/OUTPUT/X64/ExceptionHandlerAsm.iii
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib/OUTPUT/X64/ExceptionHandlerAsm.iii:569:no
> such instruction: `retf'
> make: ***
> [/Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib/OUTPUT/X64/ExceptionHandlerAsm.obj]
> Error 1
>
> This is the code in question:
>
> DoReturn:
> pushq %rax
> movabsq ASM_PFX(mDoFarReturnFlag), %rax
> cmpq $0, %rax # Check if need to do far return instead of IRET
> popq %rax
> jz DoIret
> pushq %rax
> movq %rsp, %rax # save old RSP to rax
> movq 0x20(%rsp), %rsp
> pushq 0x10(%rax) # save CS in new location
> pushq 0x8(%rax) # save EIP in new location
> pushq 0x18(%rax) # save EFLAGS in new location
> movq (%rax), %rax # restore rax
> popfq # restore EFLAGS
> .byte 0x48 # prefix to composite "retq" with next "retf"
> retf # far return
>
> I changed the `retf` to a `ret` to get it to assemble for now.
>
That looks right. I think it should be ret.
> Issue #2
>
> Next issue is with the ACPI tables:
>
> Building ... /Users/x/code/ext/edk2/OvmfPkg/AcpiTables/AcpiTables.inf [X64]
> Trim --asl-file -o
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Ssdt.i
> -i
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/inc.lst
> /Users/x/code/ext/edk2/OvmfPkg/AcpiTables/Ssdt.asl
> "clang" -x c -E -I/Users/x/code/ext/edk2/OvmfPkg/AcpiTables
> -I/Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/DEBUG
> -I/Users/x/code/ext/edk2/MdePkg -I/Users/x/code/ext/edk2/MdePkg/Include
> -I/Users/x/code/ext/edk2/MdePkg/Include/X64
> -I/Users/x/code/ext/edk2/OvmfPkg/AcpiTables
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Ssdt.i
> >
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Ssdt.iii
> "iasl"
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Ssdt.aml
>
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Ssdt.iii
> Error 6092 - Could not open file
> "/Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Ssdt.aml"
> (No such file or directory)
>
> I’m not familiar with compiling ASL, so I’m not sure what’s going on here,
> but it seems like a bad invocation of `iasl`. I installed the `acpica`
> package from homebrew, which contains `iasl`.
>
> $ iasl -v
>
> Intel ACPI Component Architecture
> ASL Optimizing Compiler version 20130823-64 [Jun 20 2014]
> Copyright (c) 2000 - 2013 Intel Corporation
>
> The intermediate files look like this:
>
> Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Ssdt.i:
>
> #undef MIN
> #undef MAX
> /** @file
> <snip>
> **/
>
> DefinitionBlock ("Ssdt.aml", "SSDT", 1, "REDHAT", "OVMF ", 1) {
> }
>
> Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/inc.lst:
>
> -I/Users/x/code/ext/edk2/OvmfPkg/AcpiTables
> -I/Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/DEBUG
> -I/Users/x/code/ext/edk2/MdePkg
> -I/Users/x/code/ext/edk2/MdePkg/Include
> -I/Users/x/code/ext/edk2/MdePkg/Include/X64
>
> Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Ssdt.iii:
>
> # 1
> "/Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Ssdt.i"
> # 1 "<built-in>" 1
> # 1 "<built-in>" 3
> # 170 "<built-in>" 3
> # 1 "<command line>" 1
> # 1 "<built-in>" 2
> # 1
> "/Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Ssdt.i"
> 2
> # 20
> "/Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Ssdt.i"
> DefinitionBlock ("Ssdt.aml", "SSDT", 1, "REDHAT", "OVMF ", 1) {
> }
>
> The build rule for ASL files looks like this:
>
> <Command.GCC>
> Trim --asl-file -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i -i
> $(INC_LIST) ${src}
> "$(ASLPP)" $(ASLPP_FLAGS) $(INC) -I${s_path}
> $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i >
> $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
> "$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst}
> $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
>
> Any ideas?
>
Try adding:
<Command.XCODE>
Trim --asl-file -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i -i
$(INC_LIST) ${src}
"$(ASLPP)" $(ASLPP_FLAGS) $(INC) -I${s_path}
$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i >
$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
Trim --source-code -l -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii
$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
"$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst}
$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii
> Issue #3
>
> If I skip the ASL files, next issue is here:
>
> ld: symbol(s) not found for inferred architecture x86_64
> Building ... /Users/x/code/ext/edk2/OvmfPkg/AcpiTables/AcpiTables.inf [X64]
> Trim --asl-file -o
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Ssdt.i
> -i
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/inc.lst
> /Users/x/code/ext/edk2/OvmfPkg/AcpiTables/Ssdt.asl
> "clang" -x c -E -I/Users/x/code/ext/edk2/OvmfPkg/AcpiTables
> -I/Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/DEBUG
> -I/Users/x/code/ext/edk2/MdePkg -I/Users/x/code/ext/edk2/MdePkg/Include
> -I/Users/x/code/ext/edk2/MdePkg/Include/X64
> -I/Users/x/code/ext/edk2/OvmfPkg/AcpiTables
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Ssdt.i
> >
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Ssdt.iii
> "clang" -o
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Madt.obj
> -x c -save-temps -g -O0 -fshort-wchar -fno-strict-aliasing -Wall -Werror
> -Wno-missing-braces -c -include AutoGen.h -mdynamic-no-pic
> -I/Users/x/code/ext/edk2/OvmfPkg/AcpiTables
> -I/Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/DEBUG
> -I/Users/x/code/ext/edk2/MdePkg -I/Users/x/code/ext/edk2/MdePkg/Include
> -I/Users/x/code/ext/edk2/MdePkg/Include/X64
> /Users/x/code/ext/edk2/OvmfPkg/AcpiTables/Madt.aslc
> "ld" -o
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Madt.dll
> -e _main -preload -segalign 0x20 -pie -seg1addr 0x240 -read_only_relocs
> suppress -map
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/DEBUG/PlatformAcpiTables.map
>
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Madt.obj
> ld: warning: -macosx_version_min not specified, assuming 10.8
> Undefined symbols for architecture x86_64:
> "_main", referenced from:
> -u command line option
> ld: symbol(s) not found for inferred architecture x86_64
>
> Not sure if the main is actually required for this guy? Again, not too
> familiar with ACPI, but just defining a dummy main function in each of the
> `aslc` files (it happens with each of them) gets past there. I suspect this
> is a change in behaviour with clang, I remember having a similar issue with
> some freestanding Rust code.
>
Try changing your *_*_*_ASLDLINK_FLAGS in Conf/tools_def.txt to look like: -e
_ReferenceAcpiTable -preload -segalign 0x20 -pie -seg1addr 0x240
-read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
So no -e _main
> Issue #4
>
> Building ... /Users/x/code/ext/edk2/MdeModulePkg/Core/Dxe/DxeMain.inf [X64]
> "ld" -arch x86_64 -u __ModuleEntryPoint -e __ModuleEntryPoint -preload
> -segalign 0x20 -pie -all_load -dead_strip -seg1addr 0x240 -map
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/MdeModulePkg/Core/Dxe/DxeMain/DEBUG/DxeCore.map
> -o
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/MdeModulePkg/Core/Dxe/DxeMain/DEBUG/DxeCore.dll
> -filelist
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/MdeModulePkg/Core/Dxe/DxeMain/OUTPUT/static_library_files.lst
> ld: illegal text-relocation to '_CommonInterruptEntry' in
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib/OUTPUT/DxeCpuExceptionHandlerLib.lib(ExceptionHandlerAsm.obj)
> from 'Exception0Handle' in
> /Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib/OUTPUT/DxeCpuExceptionHandlerLib.lib(ExceptionHandlerAsm.obj)
> for architecture x86_64
> make: ***
> [/Users/x/code/ext/edk2/Build/OvmfX64/DEBUG_XCLANG/X64/MdeModulePkg/Core/Dxe/DxeMain/DEBUG/DxeCore.dll]
> Error 1
>
> Wondering if this is a result of the `ret` instruction change I made earlier.
> That’s as far as I’m able to get so far. Any help is appreciated :)
>
No. The library has non PC relative addressing in it and this is not supported
by the linker. When building the UefiCpuPkg.dsc this library is built, but not
linked so you don’t hit this error building the package. Just linking the
library.
So things like:
movabsq ASM_PFX(mDoFarReturnFlag), %ax
Need to be:
movzbl ASM_PFX(mDoFarReturnFlag)(%rip), %eax
You need to convert any assembly code using absolute addresses to to relative
addressing.
I see that both mErrorCodeFlag and mDoFarReturnFlag are defined as C. You can
always write some C code that does the same kind of access and figure it out
that way (not sure I have all the types right, but you get the idea):
~/work/Compiler>cat mDoFarReturnFlag.c
long mDoFarReturnFlag = 1;
unsigned char
test (int i){
return mDoFarReturnFlag;
}
~/work/Compiler>clang -Os -S mDoFarReturnFlag.c
~/work/Compiler>cat mDoFarReturnFlag.S
.section __TEXT,__text,regular,pure_instructions
.globl _test
_test: ## @test
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp2:
.cfi_def_cfa_offset 16
Ltmp3:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp4:
.cfi_def_cfa_register %rbp
movzbl _mDoFarReturnFlag(%rip), %eax
popq %rbp
ret
.cfi_endproc
.section __DATA,__data
.globl _mDoFarReturnFlag ## @mDoFarReturnFlag
.align 3
_mDoFarReturnFlag:
.quad 1 ## 0x1
.subsections_via_symbols
> Thanks,
> Egon
> ------------------------------------------------------------------------------
> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
> Find What Matters Most in Your Big Data with HPCC Systems
> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
> http://p.sf.net/sfu/hpccsystems_______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel