ejschwartz commited on
Commit
1defe4d
·
1 Parent(s): 930add3

Try to use llvm-readobj

Browse files
Files changed (2) hide show
  1. Dockerfile +2 -0
  2. main.py +8 -0
Dockerfile CHANGED
@@ -7,6 +7,8 @@ WORKDIR /code
7
 
8
  COPY ./requirements.txt /code/requirements.txt
9
 
 
 
10
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
11
 
12
  # Set up a new user named "user" with user ID 1000
 
7
 
8
  COPY ./requirements.txt /code/requirements.txt
9
 
10
+ RUN bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
11
+
12
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
13
 
14
  # Set up a new user named "user" with user ID 1000
main.py CHANGED
@@ -2,6 +2,7 @@ import editdistance
2
  import frontmatter
3
  from hexdump2 import hexdump
4
  import gradio as gr
 
5
  import shlex
6
  import subprocess
7
  import tempfile
@@ -82,6 +83,13 @@ def compile(compiler, flags, source):
82
  ).stdout
83
  relocs = trim(relocs, 3)
84
 
 
 
 
 
 
 
 
85
  if result.returncode == 0:
86
  return relocs, compiled_bytes, compile_output, disassembly
87
  else:
 
2
  import frontmatter
3
  from hexdump2 import hexdump
4
  import gradio as gr
5
+ import json
6
  import shlex
7
  import subprocess
8
  import tempfile
 
83
  ).stdout
84
  relocs = trim(relocs, 3)
85
 
86
+ json_relocs = subprocess.run(
87
+ ["llvm-readobj", "--elf-output-style=JSON", "--relocations", temp_o_file_name],
88
+ capture_output=True,
89
+ text=True,
90
+ ).stdout
91
+ json_relocs = json.loads(json_relocs)
92
+
93
  if result.returncode == 0:
94
  return relocs, compiled_bytes, compile_output, disassembly
95
  else: