Shankar Easwaran
2013-Oct-07 02:38 UTC
[LLVMdev] [lld] Verifying the Architecture of files read
On 10/4/2013 11:16 PM, Michael Spencer wrote:> On Fri, Oct 4, 2013 at 8:50 PM, Shankar Easwaran <shankare at codeaurora.org>wrote: > >> Hi, >> >> It is needed that lld verifies the input to the linker. >> >> For example : a x86 ELF file can be given to lld when the target is >> x86_64. Similiarly with other flavors. >> >> I was thinking to have a varargs function in the LinkingContext that would >> be overridden by each of the LinkingContexts to verify files after being >> read. >> >> The reader would call the varargs function in the LinkingContext and raise >> an error if the input is not suitable with the current link mode. >> >> Thanks >> >> Shankar Easwaran >> >> -- >> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted >> by the Linux Foundation >> >> > Why would it need to be varargs?LinkingContext for ELF would require fields from the ELF header to verify if the file thats being read belongs to the current target architecture. I am not sure of how many fields would determine the same for Darwin and COFF. This is the reason I thought it should be varargs.> Also, parse can just return an error that > specifies the format is wrong.It would still need to call the LinkingContext to figure out if the format is associated with the target.> Specifically this would be a good place to use the user data part of > ErrorOr to specify what was expected and what was received.Couldnt follow this. Can you elaborate ? Thanks Shankar Easwaran -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation
Michael Spencer
2013-Oct-07 22:13 UTC
[LLVMdev] [lld] Verifying the Architecture of files read
On Sun, Oct 6, 2013 at 7:38 PM, Shankar Easwaran <shankare at codeaurora.org>wrote:> On 10/4/2013 11:16 PM, Michael Spencer wrote: > >> On Fri, Oct 4, 2013 at 8:50 PM, Shankar Easwaran <shankare at codeaurora.org >> >**wrote: >> >> Hi, >>> >>> It is needed that lld verifies the input to the linker. >>> >>> For example : a x86 ELF file can be given to lld when the target is >>> x86_64. Similiarly with other flavors. >>> >>> I was thinking to have a varargs function in the LinkingContext that >>> would >>> be overridden by each of the LinkingContexts to verify files after being >>> read. >>> >>> The reader would call the varargs function in the LinkingContext and >>> raise >>> an error if the input is not suitable with the current link mode. >>> >>> Thanks >>> >>> Shankar Easwaran >>> >>> -- >>> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted >>> by the Linux Foundation >>> >>> >>> Why would it need to be varargs? >> > LinkingContext for ELF would require fields from the ELF header to verify > if the file thats being read belongs to the current target architecture. > > I am not sure of how many fields would determine the same for Darwin and > COFF. > > This is the reason I thought it should be varargs.The reader has an {ELF,COFF,Darwin}LinkingContext. It can just ask the context.> > Also, parse can just return an error that >> specifies the format is wrong. >> > It would still need to call the LinkingContext to figure out if the format > is associated with the target.Exactly.> > Specifically this would be a good place to use the user data part of >> ErrorOr to specify what was expected and what was received. >> > Couldnt follow this. Can you elaborate ?ErrorOr supports user data. See unittests/Support/ErrorOrTest.cpp. It would simply be: return ArchMismatch(expected, actual); Then an error handler higher up can extract that to form a proper error message. - Michael Spencer> > > Thanks > > Shankar Easwaran > > -- > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted > by the Linux Foundation > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131007/8e20737e/attachment.html>
Shankar Easwaran
2013-Oct-07 22:19 UTC
[LLVMdev] [lld] Verifying the Architecture of files read
On 10/7/2013 5:13 PM, Michael Spencer wrote:> On Sun, Oct 6, 2013 at 7:38 PM, Shankar Easwaran <shankare at codeaurora.org>wrote: > >> On 10/4/2013 11:16 PM, Michael Spencer wrote: >> >>> On Fri, Oct 4, 2013 at 8:50 PM, Shankar Easwaran <shankare at codeaurora.org >>>> **wrote: >>> Hi, >>>> It is needed that lld verifies the input to the linker. >>>> >>>> For example : a x86 ELF file can be given to lld when the target is >>>> x86_64. Similiarly with other flavors. >>>> >>>> I was thinking to have a varargs function in the LinkingContext that >>>> would >>>> be overridden by each of the LinkingContexts to verify files after being >>>> read. >>>> >>>> The reader would call the varargs function in the LinkingContext and >>>> raise >>>> an error if the input is not suitable with the current link mode. >>>> >>>> Thanks >>>> >>>> Shankar Easwaran >>>> >>>> -- >>>> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted >>>> by the Linux Foundation >>>> >>>> >>>> Why would it need to be varargs? >> LinkingContext for ELF would require fields from the ELF header to verify >> if the file thats being read belongs to the current target architecture. >> >> I am not sure of how many fields would determine the same for Darwin and >> COFF. >> >> This is the reason I thought it should be varargs. > > The reader has an {ELF,COFF,Darwin}LinkingContext. It can just ask the > context.This would make it not part of the LinkingContext interface then. I was thinking of a pure virtual function defined in LinkingContext and all LinkingContexts to implement the function in their code.> Specifically this would be a good place to use the user data part of >>> ErrorOr to specify what was expected and what was received. >>> >> Couldnt follow this. Can you elaborate ? > > ErrorOr supports user data. See unittests/Support/ErrorOrTest.cpp. > > It would simply be: return ArchMismatch(expected, actual); > > Then an error handler higher up can extract that to form a proper error > message.Ok. Thanks Shankar Easwaran
Seemingly Similar Threads
- [LLVMdev] [lld] Verifying the Architecture of files read
- [LLVMdev] [lld] Verifying the Architecture of files read
- [LLVMdev] [lld] Verifying the Architecture of files read
- [LLVMdev] [lld] Verifying the Architecture of files read
- [LLVMdev] [lld] Verifying the Architecture of files read