> -----Original Message-----
> From: af...@apple.com [mailto:af...@apple.com]
> Sent: Tuesday, March 29, 2016 4:09 PM
> To: Vladimir Olovyannikov
> Cc: Eugene Cohen; Ard Biesheuvel; edk2-devel@lists.01.org
> Subject: Re: [edk2] Error while loading a symbol file (No Debug
Directory)
>
>
> > On Mar 29, 2016, at 3:18 PM, Vladimir Olovyannikov
> <vladimir.olovyanni...@broadcom.com> wrote:
> >
> > A quick update on the issue (I am using the latest master branch
tree).
> >
> > Eugene is right in that excluding ImageContext->SizeOfHeaders gives
> > correct address, and using
> > "add-symbol-file...." I can do source level debugging in the DS-5
> > debugger.
> > So it was sufficient to change
> > ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
> > (around line 94)
> > DEBUG ((EFI_D_LOAD | EFI_D_INFO, "add-symbol-file %a 0x%p\n",
> >     DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof
> > (Temp)),
> >     (UINTN)(ImageContext->ImageAddress +
> > ImageContext->SizeOfHeaders)));
> > to
> > DEBUG ((EFI_D_LOAD | EFI_D_INFO, "add-symbol-file %a 0x%p\n",
> >     DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof
> > (Temp)),
> >      (UINTN)(ImageContext->ImageAddress)));
> >
> > as well as around line 131 (which is optional) ("remove-symbol-file").
> > It is probably a dirty hack but works fine for me.
>
> Vladimir,
>
> I'm not sure what is happening in your case but in general we run into
issues
> when converting other executable formats (ELF, Mach-O) into PE/COFF as
> PE/COFF has the concept of the COFF header being loaded into system
> memory and other formats do not. So adding in ImageContext-
> >SizeOfHeaders is adjusting for the difference between how the ELF was
> constructed prior to conversion to PE/COFF. In some cases the ELF is
linked
> with an adjustment for the PE/COFF header and in this case you tend to
use
> the start of the image. If the ELF image was just linked at zero then
you need
> to adjust for the size of the PE/COFF header.
>
> It looks like the GCC linker script BaseTools/Scripts/GccBase.lds does
some
> link time adjustment to leave size for the PE/COFF header. Thus these
> toolchains would probably need to use ImageContext->ImageAddress vs.
> ImageContext->ImageAddress + ImageContext->SizeOfHeaders. It also looks
> like the RVCT has a linker script that reservers 0x220 bytes for a
PE/COFF
> header.
>
> The, slightly mangled, comment right before the GCC add-symbol-file
DEBUG
> print is pointing out the + ImageContext->SizeOfHeaders could be
optional. I
> would think if you are linking the ELF to include space for the PE/COFF
header
> then you should fall into the no + ImageContext->SizeOfHeaders is
required.
>
>     // This may not work correctly if you generate PE/COFF directlyas
then the
> Offset would not be required
>
> So I wonder if these DEBUG prints are out of sync with the current
linker
> flags? If I thought  the add-symbol-file address was always the start of
the
> image. Adding in the PE/COFF SizeOfHeaders would only bee needed if the
> ELF was constructed without adjustment for the PE/COFF header. Looks
like
> most of the targets do this adjustment?
>
> Thanks,
>
> Andrew Fish
Thanks for the input Andrew,
For me it all started only after applying of commit
2939c778a3a3f5463d97339f4f3dbf5afb572a5e,
ArmPkg: ARM/AArch64 implementation of CpuExceptionHandlerLib,
though I do not see how this commit could affect (SizeOfHeaders + Base)
address...

As soon as I checkout the previous
(d2bb61a2328d512c0aeb201ab8a5a6497f415afb,
ArmPkg/ArmLib: add ArmReadHcr to enable read-modify-write of HCR),
everything is fine.

The commit f37d891c1b870b294964adf65f619a661700fcab,
BaseTools AARCH64: move DEBUG GCC49 to the small code model,
causes this when I run cmd_load_symbols.py script in DS-5 debugger:
Add symbols of
/uefi/Build/NS2Pkg/DEBUG_GCC49/AARCH64/ArmPlatformPkg/PrePi/PeiMPCore/DEBU
G/ArmPlatformPrePiMPCore.dll at 0x85000000
Error while loading a symbol file (EfiFileSectionPE64: No Debug Directory)
...Same line 30 times...
Error while loading a symbol file (EfiFileSectionPE64: No Debug Directory)
Add symbols of
/work/jenkins/workspace/ap-uefi-bin/EDK2_ARCH/ARM/EDK2_BINARY/FatPkg/label
/sas-sw/Build/Fat/RELEASE_GCC49/AARCH64/FatPkg/EnhancedFatDxe/Fat/DEBUG/Fa
t.dll at 0xb9f85000
Warning: not possible to load symbols from
/work/jenkins/workspace/ap-uefi-bin/EDK2_ARCH/ARM/EDK2_BINARY/FatPkg/label
/sas-sw/Build/Fat/RELEASE_GCC49/AARCH64/FatPkg/EnhancedFatDxe/Fat/DEBUG/Fa
t.dll at 0xb9f85000
Error while loading a symbol file (EfiFileSectionPE64: No Debug Directory)
...Same line 12 times....
Error while loading a symbol file (EfiFileSectionPE64: No Debug Directory)

This does not affect add-symbol-file debugging, whereas
cmd_load_symbols.py script was useless since
2939c778a3a3f5463d97339f4f3dbf5afb572a5e commit.
I think there is a line which adds SizeOfHeaders (or similar) to the base
address in a DS-5 python script,
but I am not familiar with the design, and as soon as "add-symbol-file"
works for me, I am OK.

I am wondering if I am the only one who is affected with this DS-5 script
behavior?

Thank you,
Vladimir
>
> > However ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py script is
> useless
> > because it does not load the symbols properly.
> > Anyway at least I have an ability to do source level debug now using
> > "add-symbol-file" lines.
> >
> > Thank you,
> > Vladimir
> >> -----Original Message-----
> >> From: Vladimir Olovyannikov
> [mailto:vladimir.olovyanni...@broadcom.com]
> >> Sent: Friday, March 25, 2016 7:17 PM
> >> To: 'Cohen, Eugene'; 'Ard Biesheuvel'
> >> Cc: 'edk2-devel@lists.01.org'
> >> Subject: RE: [edk2] Error while loading a symbol file (No Debug
> > Directory)
> >>
> >>>> This is very odd. The commit in question introduces two new
> >>>> implementations of CpuExceptionHandlerLib, but does not yet use
> them
> >>>> anywhere. The next patch updates CpuDxe to start using the default
> >>>> (non-copying) one. What are your resolutions for
> >> CpuExceptionHandlerLib
> >>> in
> >>>> your .DSC, and do any of them refer to the libraries added in this
> > patch?
> >>>
> >>> Agreed - from a CpuDxe point of view the change should be
transparent
> > -
> >>> it's the same exception handling implemented in a library.  It
should
> > have
> >>> the same alignment characteristics as before.  If there was a bug
that
> >>> existing in debug scripts for scanning modules or PE-coff extra
> > actions - I
> >>> would not expect this patch to worsen (or improve) the situation.
> >> I totally agree with you. However, I re-verified one more time, and
this
> > is the
> >> patch
> >> after which no source level debugging is available for me.
> >>>
> >>>>> If I do "add-symbol-file.." in the DS-5 Debug console as the
> > exception
> >>>>> handler reports, I have an ability to debug (so the address is
> > shifted
> >>>>> +0x10000 comparing to the proper address) Do you know if  anybody
> >> else
> >>>>> had this issue on an armv8 64 bit platform after this patch was
> >>>>> applied?
> >>>>> Please advise what I could be missing...
> >>>>>
> >>>>
> >>>> Hmm, that looks like a separate issue. Due to the padding required
> > for
> >>>> runtime drivers, which have a 64k section alignment, the start of
> > the file
> >>> and
> >>>> the start of the text section are 64k apart, so that output is not
> >>> unexpected.
> >>>> In GDB, add-symbol-file takes the start of the .text section, not
> > the start
> >> of
> >>>> the image.
> >>>
> >>> Are you saying this also started happening with the commit in
question
> > or is
> >>> that something independent?
> >> Eugene, I think there is actually one issue.
> >> It looks like "No debug directory" message was from day 1 (last year,
> >> sometime Jul) for me,
> >> but it did not affect debugging in any way, so I simply ignored it.
> >> With this commit the source level debugging (we use DS-5) is
unavailable
> > for
> >> me, even though debugger says
> >> that symbols were loaded successfully. For the driver of interest
(say
> >> RuntimeClock...) I manually shift  -0x10000, and
> >> then the source-level debugging is available again.
> >>
> >> As Ard says if the debugger needs the start of
> >>> .text then this address may not be correct since the output is
> > generated as
> >>> follows:
> >>>
> >>>    DEBUG ((EFI_D_LOAD | EFI_D_INFO, "add-symbol-file %a 0x%p\n",
> >>> DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof
> >> (Temp)),
> >>> (UINTN)(ImageContext->ImageAddress + ImageContext-
> >>> SizeOfHeaders)));
> >>>
> >>> With our debugger (TRACE32) we only emit ImageAddress and don't add
> >>> SizeOfHeaders:
> >>>
> >>>   DEBUG((EFI_D_ERROR, "data.load.elf %a a:0x%08x /NOCODE
> >> /NOCLEAR\n",
> >>> ImageContext->PdbPointer, ImageAddress));
> >>>
> >>> The adding of SizeOfHeaders used to be required when the PE-COFF
> >>> conversion would shift the .text section to make room for the
PE-COFF
> >>> header but recent changes made the ELF and PE-COFF layout align so
> > that
> >>> this offset was no longer necessary.
> >>>
> >>> Eugene
> >>
> >> Ard, Eugene,
> >> Here is the section from the dsc.
> >> I am building a DEBUG version,
> >> ARM_BDS is not used,
> >> SECURE BOOT is disabled.
> >>
> >> If you spot anything suspicious or need additional info please let me
> > know.
> >>
> >> ------ Starts here
> >> [LibraryClasses.common]
> >> !if $(TARGET) == RELEASE
> >>  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
> >>
> >>
> UncachedMemoryAllocationLib|ArmPkg/Library/UncachedMemoryAllocatio
> >> nLib/UncachedMemoryAllocationLib.inf
> >> !else
> >>
> >>
> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.
> >> inf
> >>
> >>
> UncachedMemoryAllocationLib|ArmPkg/Library/UncachedMemoryAllocatio
> >> nLib/UncachedMemoryAllocationLib.inf
> >> #
> >>
> UncachedMemoryAllocationLib|ArmPkg/Library/DebugUncachedMemoryAll
> >> ocationLib/DebugUncachedMemoryAllocationLib.inf
> >> !endif
> >>
> >>
> DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/Bas
> >> eDebugPrintErrorLevelLib.inf
> >>
> >>  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
> >>
> >>
> SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroniz
> >> ationLib.inf
> >>
> >>
> PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanc
> >> eLibNull.inf
> >>  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
> >>
> >>
> PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/Base
> >> PeCoffGetEntryPointLib.inf
> >>  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
> >>  IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
> >>
> >>
> UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDeco
> >> mpressLib.inf
> >>  CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
> >>
> >>  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
> >>  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
> >>
> >>
> UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib
> >> /UefiRuntimeServicesTableLib.inf
> >>  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
> >>
> >>
> UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBo
> >> otServicesTableLib.inf
> >>
> >>
> DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTabl
> >> eLib.inf
> >>
> >>
> UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntry
> >> Point.inf
> >>
> >>
> UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiA
> >> pplicationEntryPoint.inf
> >>  HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
> >>
> >>
> >
>
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiService
> >> sLib.inf
> >>
> >>  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
> >>
> >>  #
> >>  # Assume everything is fixed at build
> >>  #
> >>  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
> >>
> >>  # 1/123 faster than Stm or Vstm version
> >>  #BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
> >>
> >>
> BaseMemoryLib|ArmPkg/Library/BaseMemoryLibStm/BaseMemoryLibStm.i
> >> nf
> >>
> >>  # Networking Requirements
> >>  NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
> >>  DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
> >>  UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
> >>  IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
> >>
> >>  # ARM Architectural Libraries
> >>
> >>
> CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCach
> >> eMaintenanceLib.inf
> >>
> >>
> DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/D
> >> efaultExceptionHandlerLib.inf
> >>
> >>
> CpuExceptionHandlerLib|ArmPkg/Library/ArmExceptionLib/ArmExceptionLib
> >> .inf
> >>
> >>
> ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler
> >> Lib.inf
> >>  DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf
> >>  ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
> >>  ArmGicArchLib|ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf
> >>
> >>
> ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPla
> >> tformStackLib.inf
> >>  ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> >>
> >>
> ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounter
> >> Lib/ArmGenericTimerPhyCounterLib.inf
> >>
> >>  PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
> >>
> >>  # ARM SP804 Dual Timer Driver
> >>  TimerLib|ArmPlatformPkg/Library/SP804TimerLib/SP804TimerLib.inf
> >>
> >>  # EBL Related Libraries
> >>  EblCmdLib|ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf
> >>  EfiFileLib|EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf
> >>
> >>
> EblAddExternalCommandLib|EmbeddedPkg/Library/EblAddExternalComman
> >> dLib/EblAddExternalCommandLib.inf
> >>  EblNetworkLib|EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf
> >>
> >>  #
> >>  # Uncomment (and comment out the next line) For RealView Debugger.
> >> The Standard IO window
> >>  # in the debugger will show load and unload commands for symbols.
You
> >> can cut and paste this
> >>  # into the command window to load symbols. We should be able to use
a
> >> script to do this, but
> >>  # the version of RVD I have does not support scripts accessing
system
> >> memory.
> >>  #
> >>
> >>
> #PeCoffExtraActionLib|ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoff
> >> ExtraActionLib.inf
> >>
> >>
> PeCoffExtraActionLib|ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPe
> >> CoffExtraActionLib.inf
> >>
> >>
> #PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/Base
> >> PeCoffExtraActionLibNull.inf
> >>
> >>
> >>
> DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLi
> >> bNull.inf
> >>
> >>
> DebugAgentTimerLib|EmbeddedPkg/Library/DebugAgentTimerLibNull/Debu
> >> gAgentTimerLibNull.inf
> >>
> >>  SemihostLib|ArmPkg/Library/SemihostLib/SemihostLib.inf
> >>
> >>  # BDS Libraries
> >>  BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf
> >>
> >>  AcpiLib|EmbeddedPkg/Library/AcpiLib/AcpiLib.inf
> >>  FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
> >>
> >>  # RunAxf support via Dynamic Shell Command protocol
> >>  # It uses the Shell libraries.
> >>
> >>
> ArmShellCmdRunAxfLib|ArmPlatformPkg/Library/ArmShellCmdRunAxf/Arm
> >> ShellCmdRunAxf.inf
> >>  ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
> >>  FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
> >>  SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
> >>
> >>  #
> >>  # Secure Boot dependencies
> >>  #
> >> !if $(SECURE_BOOT_ENABLE) == TRUE
> >>  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
> >>  OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
> >>
> >>
> TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTp
> >> mMeasurementLib.inf
> >>
> >
AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
> >>  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
> >>
> >>  # re-use the UserPhysicalPresent() dummy implementation from the
> ovmf
> >> tree
> >>
> >>
> PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.i
> >> nf
> >> !else
> >>
> >>
> TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/Tp
> >> mMeasurementLibNull.inf
> >>
> >>
> AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableL
> >> ibNull.inf
> >> !endif
> >>  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
> >>
> >> !if $(USE_ARM_BDS) == FALSE
> >>
> >>
> CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.i
> >> nf
> >>
> >>
> GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericB
> >> dsLib.inf
> >>
> >>
> PlatformBdsLib|ArmPlatformPkg/Library/PlatformIntelBdsLib/PlatformIntelB
> >> dsLib.inf
> >>
> >>
> CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/Custo
> >> mizedDisplayLib.inf
> >> !endif
> >>
> >> ---Ends here
> >>
> >> Thank you,
> >> Vladimir
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to