mirror of
https://github.com/danog/gllvm.git
synced 2024-11-30 06:19:03 +01:00
extractor: Make extraction errors fatal
This commit is contained in:
parent
8110c3fb00
commit
3d3264fd14
@ -257,7 +257,10 @@ func resolveTool(defaultPath string, envPath string, usrPath string) (path strin
|
|||||||
|
|
||||||
func handleExecutable(ea ExtractionArgs) (success bool) {
|
func handleExecutable(ea ExtractionArgs) (success bool) {
|
||||||
// get the list of bitcode paths
|
// get the list of bitcode paths
|
||||||
artifactPaths := ea.Extractor(ea.InputFile)
|
artifactPaths, success := ea.Extractor(ea.InputFile)
|
||||||
|
if !success {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if len(artifactPaths) < 20 {
|
if len(artifactPaths) < 20 {
|
||||||
// naert: to avoid saturating the log when dealing with big file lists
|
// naert: to avoid saturating the log when dealing with big file lists
|
||||||
@ -671,40 +674,46 @@ func linkBitcodeFiles(ea ExtractionArgs, filesToLink []string) (success bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractSectionDarwin(inputFile string) (contents []string) {
|
func extractSectionDarwin(inputFile string) (contents []string, success bool) {
|
||||||
machoFile, err := macho.Open(inputFile)
|
machoFile, err := macho.Open(inputFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LogError("Mach-O file %s could not be read.", inputFile)
|
LogError("Mach-O file %s could not be read.", inputFile)
|
||||||
|
success = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
section := machoFile.Section(DarwinSectionName)
|
section := machoFile.Section(DarwinSectionName)
|
||||||
if section == nil {
|
if section == nil {
|
||||||
LogWarning("The %s section of %s is missing!\n", DarwinSectionName, inputFile)
|
LogError("The %s section of %s is missing!\n", DarwinSectionName, inputFile)
|
||||||
|
success = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sectionContents, errContents := section.Data()
|
sectionContents, errContents := section.Data()
|
||||||
if errContents != nil {
|
if errContents != nil {
|
||||||
LogWarning("Error reading the %s section of Mach-O file %s.", DarwinSectionName, inputFile)
|
LogError("Error reading the %s section of Mach-O file %s.", DarwinSectionName, inputFile)
|
||||||
|
success = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
contents = strings.Split(strings.TrimSuffix(string(sectionContents), "\n"), "\n")
|
contents = strings.Split(strings.TrimSuffix(string(sectionContents), "\n"), "\n")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractSectionUnix(inputFile string) (contents []string) {
|
func extractSectionUnix(inputFile string) (contents []string, success bool) {
|
||||||
elfFile, err := elf.Open(inputFile)
|
elfFile, err := elf.Open(inputFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LogError("ELF file %s could not be read.", inputFile)
|
LogError("ELF file %s could not be read.", inputFile)
|
||||||
|
success = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
section := elfFile.Section(ELFSectionName)
|
section := elfFile.Section(ELFSectionName)
|
||||||
if section == nil {
|
if section == nil {
|
||||||
LogWarning("Error reading the %s section of ELF file %s.", ELFSectionName, inputFile)
|
LogError("Error reading the %s section of ELF file %s.", ELFSectionName, inputFile)
|
||||||
|
success = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sectionContents, errContents := section.Data()
|
sectionContents, errContents := section.Data()
|
||||||
if errContents != nil {
|
if errContents != nil {
|
||||||
LogWarning("Error reading the %s section of ELF file %s.", ELFSectionName, inputFile)
|
LogError("Error reading the %s section of ELF file %s.", ELFSectionName, inputFile)
|
||||||
|
success = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
contents = strings.Split(strings.TrimSuffix(string(sectionContents), "\n"), "\n")
|
contents = strings.Split(strings.TrimSuffix(string(sectionContents), "\n"), "\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user