Created
August 12, 2020 08:48
-
-
Save sailfish009/8470dced2621ae8633f8d5ba30563728 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://forums.gentoo.org/viewtopic-t-1108872-start-0.html | |
# Python3+ instead of python2.7 | |
# by Pavel Kabikov aka bitMan | |
--- chromium-81.0.4044.26/build/toolchain/gcc_solink_wrapper.py 2020-02-20 03:32:08.000000000 +0300 | |
+++ /tmp/gcc_solink_wrapper.py 2020-02-27 00:45:25.526917216 +0300 | |
@@ -11,6 +11,7 @@ | |
""" | |
import argparse | |
+import io | |
import os | |
import subprocess | |
import sys | |
@@ -18,12 +19,19 @@ | |
import wrapper_utils | |
+def read_as_utf8(fileno): | |
+ fp = io.open(fileno, mode="r", encoding="utf-8", closefd=False) | |
+ content = fp.read() | |
+ fp.close() | |
+ return content | |
+ | |
def CollectSONAME(args): | |
"""Replaces: readelf -d $sofile | grep SONAME""" | |
toc = '' | |
readelf = subprocess.Popen(wrapper_utils.CommandToRun( | |
[args.readelf, '-d', args.sofile]), stdout=subprocess.PIPE, bufsize=-1) | |
- for line in readelf.stdout: | |
+ # print(readelf.stdout) | |
+ for line in read_as_utf8(readelf.stdout.fileno()): | |
if 'SONAME' in line: | |
toc += line | |
return readelf.wait(), toc | |
@@ -35,7 +43,7 @@ | |
nm = subprocess.Popen(wrapper_utils.CommandToRun([ | |
args.nm, '--format=posix', '-g', '-D', args.sofile]), | |
stdout=subprocess.PIPE, bufsize=-1) | |
- for line in nm.stdout: | |
+ for line in read_as_utf8(nm.stdout.fileno()): | |
toc += ' '.join(line.split(' ', 2)[:2]) + '\n' | |
return nm.wait(), toc |
Author
sailfish009
commented
Aug 12, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment