aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2012-12-15 15:03:23 -0500
committerAnthony G. Basile <blueness@gentoo.org>2012-12-15 15:03:23 -0500
commitb7ba4e91d13b546a6b5fb6e44b9d3ac465fb9141 (patch)
tree9ef46905cb1318dcbf9c6b70839186aae80637a5 /scripts
parenttests/revdeppaxtest: improve test flags (diff)
downloadelfix-b7ba4e91d13b546a6b5fb6e44b9d3ac465fb9141.tar.gz
elfix-b7ba4e91d13b546a6b5fb6e44b9d3ac465fb9141.tar.bz2
elfix-b7ba4e91d13b546a6b5fb6e44b9d3ac465fb9141.zip
scripts/revdep-pax: clean up flag exporter/importer logic
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/revdep-pax51
1 files changed, 22 insertions, 29 deletions
diff --git a/scripts/revdep-pax b/scripts/revdep-pax
index 9a990a2..8626e95 100755
--- a/scripts/revdep-pax
+++ b/scripts/revdep-pax
@@ -189,27 +189,19 @@ def run_reverse(verbose, executable_only):
def migrate_flags(importer, exporter_str_flags, exporter_bin_flags):
# We implement the following logic for setting the pax flags
- # on the target elf object, the 'importer', given that the
- # flags from the elf object we want it to match to, the exporter.
+ # on the target elf object, the IMPORTER, given that the flags
+ # from the elf object we want it to match to, the EXPORTER.
#
- # Importer Exporter Result
- # Force On Force On Force On
- # Force On Force Off Force On + Warn
- # Force On Nothing Force On
- # Force Off Force On Force Off + Warn
- # Force Off Force Off Force Off
- # Force Off Nothing Force Off
- # Nothing Force On Force On
- # Nothing Force Off Force Off
- # Nothing Nothing Nothing
- #
- # The algorithm proceeds by assuming the resulting flags = the exporter
- # flags and then changes them in cases where that's not what we want, ie
- #
- # Force On Force Off Force On + Warn
- # Force On Nothing Force On
- # Force Off Force On Force Off + Warn
- # Force Off Nothing Force Off
+ # EXPORTER IMPORTER RESULT
+ # On On On
+ # On Off On + Warn
+ # On - On
+ # Off On On + Warn
+ # Off Off Off
+ # Off - Off
+ # - On On
+ # - Off Off
+ # - - -
#See /usr/include/elf.h for these values
pf_flags = {
@@ -223,22 +215,23 @@ def migrate_flags(importer, exporter_str_flags, exporter_bin_flags):
( importer_str_flags, importer_bin_flags ) = pax.getflags(importer)
+ # Start with the exporter's flags
result_bin_flags = exporter_bin_flags
for i in range(len(importer_str_flags)):
- if importer_str_flags[i].isupper() and exporter_str_flags[i].islower():
- result_bin_flags = result_bin_flags ^ pf_flags[exporter_str_flags[i]]
- result_bin_flags = result_bin_flags | pf_flags[importer_str_flags[i]]
- print('\t\tWarning: %s has %s, refusing to set to %s' % (
- importer, importer_str_flags[i], exporter_str_flags[i] )),
- if importer_str_flags[i].isupper() and exporter_str_flags[i] == '-':
- result_bin_flags = result_bin_flags | pf_flags[importer_str_flags[i]]
- if importer_str_flags[i].islower() and exporter_str_flags[i].isupper():
+
+ # The exporter's flag contradicts the importer's flag, so do nothing
+ if (exporter_str_flags[i].isupper() and importer_str_flags[i].islower()) or \
+ (exporter_str_flags[i].islower() and importer_str_flags[i].isupper()):
+
+ # Revert the exporter's flag, use the importer's flag and warn
result_bin_flags = result_bin_flags ^ pf_flags[exporter_str_flags[i]]
result_bin_flags = result_bin_flags | pf_flags[importer_str_flags[i]]
print('\t\tWarning: %s has %s, refusing to set to %s' % (
importer, importer_str_flags[i], exporter_str_flags[i] )),
- if importer_str_flags[i].islower() and exporter_str_flags[i] == '-':
+
+ # The exporter's flags is off, so use the importer's flag
+ if (exporter_str_flags[i] == '-' and importer_str_flags[i] != '-'):
result_bin_flags = result_bin_flags | pf_flags[importer_str_flags[i]]
pax.setbinflags(importer, result_bin_flags)