SHA256
1
0
forked from pool/rpmlint

Accepting request 717603 from home:marxin:branches:devel:openSUSE:Factory:rpmlint

- Add add-check-for-a-non-zero-.text-segment-in-.a-archive.patch
  as a backport of:
  2c809f3435

OBS-URL: https://build.opensuse.org/request/show/717603
OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=675
This commit is contained in:
Dirk Mueller 2019-07-24 09:18:26 +00:00 committed by Git OBS Bridge
parent 611ecea41d
commit defff5a11b
3 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,75 @@
diff --git a/BinariesCheck.py b/BinariesCheck.py
index 36d73f8..8200f1b 100644
--- a/BinariesCheck.py
+++ b/BinariesCheck.py
@@ -73,6 +73,10 @@ class BinaryInfo(object):
mktemp_call_regex = create_regexp_call('mktemp')
lto_section_name_prefix = '.gnu.lto_.'
+ # [Nr] Name Type Address Off Size ES Flg Lk Inf Al
+ # [ 1] .text PROGBITS 0000000000000000 000040 000000 00 AX 0 0 1
+ text_section_regex = re.compile(r'.*\.text\s*\w+\s*\w*\s*\w*\w*\s*(\w*).*')
+
def __init__(self, pkg, path, fname, is_ar, is_shlib):
self.readelf_error = False
self.needed = []
@@ -92,6 +96,7 @@ class BinaryInfo(object):
self.symtab = False
self.tail = ''
self.lto_sections = False
+ self.no_text_in_archive = False
self.setgid = False
self.setuid = False
@@ -102,6 +107,7 @@ class BinaryInfo(object):
self.mktemp = False
is_debug = path.endswith('.debug')
+ is_archive = path.endswith('.a')
# Currently this implementation works only on specific
# architectures due to reliance on arch specific assembly.
if (pkg.arch.startswith('armv') or pkg.arch == 'aarch64'):
@@ -117,6 +123,22 @@ class BinaryInfo(object):
('readelf', '-W', '-S', '-l', '-d', '-s', path))
if not res[0]:
lines = res[1].splitlines()
+
+ # For an archive, test if all .text sections are empty
+ if is_archive:
+ has_text_segment = False
+ non_zero_text_segment = False
+
+ for line in lines:
+ r = self.text_section_regex.search(line)
+ if r:
+ has_text_segment = True
+ size = int(r.group(1), 16)
+ if size > 0:
+ non_zero_text_segment = True
+ if has_text_segment and not non_zero_text_segment:
+ self.no_text_in_archive = True
+
for line in lines:
if BinaryInfo.lto_section_name_prefix in line:
self.lto_sections = True
@@ -522,6 +544,9 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
if bin_info.lto_sections:
printError(pkg, 'lto-bytecode', fname)
+ if bin_info.no_text_in_archive:
+ printError(pkg, 'lto-no-text-in-archive', fname)
+
for ec in bin_info.forbidden_calls:
printWarning(pkg, ec, fname,
BinaryInfo.forbidden_functions[ec]['f_name'])
@@ -846,6 +871,10 @@ implementations only strip if the permission is 0755).''',
'lto-bytecode',
'''This executable contains a LTO section. LTO bytecode is not portable
and should not be distributed in static libraries or e.g. Python modules.''',
+
+'lto-no-text-in-archive',
+'''This archive does not contain a non-empty .text section. The archive
+was not created with -ffat-lto-objects option.''',
)
# BinariesCheck.py ends here

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Jul 22 11:44:51 UTC 2019 - Martin Liška <mliska@suse.cz>
- Add add-check-for-a-non-zero-.text-segment-in-.a-archive.patch
as a backport of:
https://github.com/rpm-software-management/rpmlint/commit/2c809f34354d6ea690986541b268d47a3ca59092
-------------------------------------------------------------------
Tue May 14 10:01:51 UTC 2019 - opensuse-packaging@opensuse.org

View File

@ -60,6 +60,7 @@ Patch58: remove-ghostfile-checks.diff
Patch63: fix-diag-sortorder.diff
Patch72: rpmlint-slpp-NUM-NUM.patch
Patch77: suse-rpmlint-all-pie.patch
Patch78: add-check-for-a-non-zero-.text-segment-in-.a-archive.patch
BuildRequires: desktop-file-utils
BuildRequires: obs-service-format_spec_file
BuildRequires: python3-flake8