glibcextract: Make compute_c_consts compatible with both clang and gcc
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
dj/TryBot-32bit |
success
|
Build for i686
|
Commit Message
clang parses the asm() contents even when using -S, so you can't
generate nonsensical code. Use normal .ascii/.long instead.
v2: Remove leftover debugging code.
Signed-off-by: Olivier Galibert <galibert@pobox.com>
---
scripts/glibcextract.py | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
@@ -45,7 +45,7 @@ def compute_c_consts(sym_data, cc):
continue
name = arg[0]
value = arg[1]
- out_lines.append('asm ("@@@name@@@%s@@@value@@@%%0@@@end@@@" '
+ out_lines.append('asm (".ascii \\\"%s\\\"\\n\\t.long %%0\\n" '
': : \"i\" ((long int) (%s)));'
% (name, value))
out_lines.append('}')
@@ -62,16 +62,21 @@ def compute_c_consts(sym_data, cc):
subprocess.check_call(cmd, shell=True)
consts = {}
with open(s_file_name, 'r') as s_file:
+ symbol = None
for line in s_file:
- match = re.search('@@@name@@@([^@]*)'
- '@@@value@@@[^0-9Xxa-fA-F-]*'
- '([0-9Xxa-fA-F-]+).*@@@end@@@', line)
+ match = re.search('[.]ascii[ \t]*"([^"]*)"', line)
if match:
- if (match.group(1) in consts
- and match.group(2) != consts[match.group(1)]):
- raise ValueError('duplicate constant %s'
- % match.group(1))
- consts[match.group(1)] = match.group(2)
+ symbol = match.group(1)
+ elif symbol != None:
+ match = re.search('[.]long[ \t]*[(]?[$]([0-9Xxa-fA-F-]+)', line)
+ if match:
+ if (symbol in consts
+ and match.group(1) != consts[symbol]):
+ raise ValueError('duplicate constant %s'
+ % symbol)
+ consts[symbol] = match.group(1)
+ else:
+ symbol = None
return consts