Another freeBSD file extension: nossppico (a position-independent relocatable object without stack smashing protection)

This commit is contained in:
Ian A Mason 2020-10-30 18:39:44 +00:00
parent 405cd117c3
commit 9f0092874f
4 changed files with 80 additions and 68 deletions

View File

@ -133,8 +133,10 @@ func buildAndAttachBitcode(compilerExecName string, pr ParserResult, bcObjLinks
}
func attachBitcodePathToObject(bcFile, objFile string) (success bool) {
success = false
// We can only attach a bitcode path to certain file types
// this is too fragile, we need to look into a better way to do this.
// We probably should be using debug/macho and debug/elf according to the OS we are atop of.
extension := filepath.Ext(objFile)
switch extension {
case
@ -142,9 +144,20 @@ func attachBitcodePathToObject(bcFile, objFile string) (success bool) {
".lo",
".os",
".So",
".pico", //iam: pico is FreeBSD
".po":
".pico", //iam: pico is FreeBSD, ".pico" denotes a position-independent relocatable object.
".nossppico", //iam: also FreeBSD, ".nossppico" denotes a position-independent relocatable object without stack smashing protection.
".po": //iam: profiled object
LogDebug("attachBitcodePathToObject recognized %v as something it can inject into.\n", extension)
success = injectPath(extension, bcFile, objFile)
default:
LogWarning("attachBitcodePathToObject ignoring unrecognized extension: %v\n", extension)
}
return
}
// move this out to concentrate on the object path analysis above.
func injectPath(extension, bcFile, objFile string) (success bool) {
success = false
// Store bitcode path to temp file
var absBcPath, _ = filepath.Abs(bcFile)
tmpContent := []byte(absBcPath + "\n")
@ -208,9 +221,6 @@ func attachBitcodePathToObject(bcFile, objFile string) (success bool) {
}
}
default:
LogWarning("attachBitcodePathToObject ignoring unrecognized extension: %v\n", extension)
}
success = true
return
}

View File

@ -59,7 +59,7 @@ package shared
// 1.2.9 October 30 2020 FreeBSD bug fixes (@arrowd) (issue #41)
const gllvmVersion = "1.2.9"
const gllvmReleaseDate = "October 30 13 2020"
const gllvmReleaseDate = "October 30 2020"
const osDARWIN = "darwin"
const osLINUX = "linux"

View File

@ -53,6 +53,9 @@ const (
fileTypeERROR
)
//iam:
// this is not that robust, because it depends on the file utility "file" which is
// often missing on docker images (the klee doker file had this problem)
func getFileType(realPath string) (fileType int) {
// We need the file command to guess the file type
cmd := exec.Command("file", realPath)
@ -96,6 +99,5 @@ func getFileType(realPath string) (fileType int) {
} else {
fileType = fileTypeUNDEFINED
}
return
}

View File

@ -397,7 +397,7 @@ func Parse(argList []string) ParserResult {
//iam: it's a bit fragile as to what we recognize as an object file.
// this also shows up in the compile function attachBitcodePathToObject, so additions
// here, should also be additions there.
{`^.+\.(o|lo|So|so|po|a|dylib|pico)$`, flagInfo{0, pr.objectFileCallback}}, //iam: pico is FreeBSD
{`^.+\.(o|lo|So|so|po|a|dylib|pico|nossppico)$`, flagInfo{0, pr.objectFileCallback}}, //iam: pico and nossppico are FreeBSD
{`^.+\.dylib(\.\d)+$`, flagInfo{0, pr.objectFileCallback}},
{`^.+\.(So|so)(\.\d)+$`, flagInfo{0, pr.objectFileCallback}},
}