|
|
@ -93,15 +93,17 @@ impl Object {
|
|
|
|
let obj = object::read::File::parse(data).map_err(|e| ParseError::ElfError(e))?;
|
|
|
|
let obj = object::read::File::parse(data).map_err(|e| ParseError::ElfError(e))?;
|
|
|
|
let endianness = obj.endianness();
|
|
|
|
let endianness = obj.endianness();
|
|
|
|
|
|
|
|
|
|
|
|
let section = obj
|
|
|
|
let license = if let Some(section) = obj.section_by_name("license") {
|
|
|
|
.section_by_name("license")
|
|
|
|
parse_license(Section::try_from(§ion)?.data)?
|
|
|
|
.ok_or(ParseError::MissingLicense)?;
|
|
|
|
} else {
|
|
|
|
let license = parse_license(Section::try_from(§ion)?.data)?;
|
|
|
|
CString::new("GPL").unwrap()
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let section = obj
|
|
|
|
let kernel_version = if let Some(section) = obj.section_by_name("version") {
|
|
|
|
.section_by_name("version")
|
|
|
|
parse_version(Section::try_from(§ion)?.data, endianness)?
|
|
|
|
.ok_or(ParseError::MissingKernelVersion)?;
|
|
|
|
} else {
|
|
|
|
let kernel_version = parse_version(Section::try_from(§ion)?.data, endianness)?;
|
|
|
|
KernelVersion::Any
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let mut bpf_obj = Object::new(endianness, license, kernel_version);
|
|
|
|
let mut bpf_obj = Object::new(endianness, license, kernel_version);
|
|
|
|
|
|
|
|
|
|
|
@ -215,18 +217,12 @@ pub enum ParseError {
|
|
|
|
#[error("error parsing ELF data")]
|
|
|
|
#[error("error parsing ELF data")]
|
|
|
|
ElfError(#[from] object::read::Error),
|
|
|
|
ElfError(#[from] object::read::Error),
|
|
|
|
|
|
|
|
|
|
|
|
#[error("no license specified")]
|
|
|
|
|
|
|
|
MissingLicense,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[error("invalid license `{data:?}`: missing NULL terminator")]
|
|
|
|
#[error("invalid license `{data:?}`: missing NULL terminator")]
|
|
|
|
MissingLicenseNullTerminator { data: Vec<u8> },
|
|
|
|
MissingLicenseNullTerminator { data: Vec<u8> },
|
|
|
|
|
|
|
|
|
|
|
|
#[error("invalid license `{data:?}`")]
|
|
|
|
#[error("invalid license `{data:?}`")]
|
|
|
|
InvalidLicense { data: Vec<u8> },
|
|
|
|
InvalidLicense { data: Vec<u8> },
|
|
|
|
|
|
|
|
|
|
|
|
#[error("missing kernel version")]
|
|
|
|
|
|
|
|
MissingKernelVersion,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[error("invalid kernel version `{data:?}`")]
|
|
|
|
#[error("invalid kernel version `{data:?}`")]
|
|
|
|
InvalidKernelVersion { data: Vec<u8> },
|
|
|
|
InvalidKernelVersion { data: Vec<u8> },
|
|
|
|
|
|
|
|
|
|
|
|