Blame scripts/check-textrel.awk
|
Packit |
6c4009 |
# This awk script expects to get command-line files that are each
|
|
Packit |
6c4009 |
# the output of 'readelf -d' on a single shared object.
|
|
Packit |
6c4009 |
# It exits successfully (0) if none contained any TEXTREL markers.
|
|
Packit |
6c4009 |
# It fails (1) if any did contain a TEXTREL marker.
|
|
Packit |
6c4009 |
# It fails (2) if the input did not take the expected form.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
BEGIN { result = textrel = sanity = 0 }
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
function check_one(name) {
|
|
Packit |
6c4009 |
if (!sanity) {
|
|
Packit |
6c4009 |
print name ": *** input did not look like readelf -d output";
|
|
Packit |
6c4009 |
result = 2;
|
|
Packit |
6c4009 |
} else if (textrel) {
|
|
Packit |
6c4009 |
print name ": *** text relocations used";
|
|
Packit |
6c4009 |
result = result ? result : 1;
|
|
Packit |
6c4009 |
} else {
|
|
Packit |
6c4009 |
print name ": OK";
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
textrel = sanity = 0;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
FILENAME != lastfile {
|
|
Packit |
6c4009 |
if (lastfile)
|
|
Packit |
6c4009 |
check_one(lastfile);
|
|
Packit |
6c4009 |
lastfile = FILENAME;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
$1 == "Tag" && $2 == "Type" { sanity = 1 }
|
|
Packit |
6c4009 |
$2 == "(TEXTREL)" { textrel = 1 }
|
|
Packit |
6c4009 |
$2 == "(FLAGS)" {
|
|
Packit |
6c4009 |
for (i = 3; i <= NF; ++i) {
|
|
Packit |
6c4009 |
if ($i == "TEXTREL")
|
|
Packit |
6c4009 |
textrel = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
END {
|
|
Packit |
6c4009 |
check_one(lastfile);
|
|
Packit |
6c4009 |
exit(result);
|
|
Packit |
6c4009 |
}
|