[LLVMdev] [lld] Verifying the Architecture of files read

Shankar Easwaran shankare at codeaurora.org
Sun Oct 6 19:38:47 PDT 2013


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




More information about the llvm-dev mailing list