Skip to content

Commit 9113ec1

Browse files
committed
make extract-bc more forgiving for archives that may contain assembled objects.
1 parent f9dc2f0 commit 9113ec1

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

extract-bc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,10 @@ def getSectionSizeAndOffset(sectionName, filename):
7777
return (size, offset)
7878
except ValueError:
7979
continue
80-
81-
# The needed section could not be found
82-
raise Exception('Could not find "{0}" ELF section in "{1}"'.format(
83-
sectionName,
84-
filename)
85-
)
80+
81+
# The needed section could not be found
82+
logging.error('Could not find "{0}" ELF section in "{1}"'.format(sectionName,filename))
83+
return None
8684

8785
# Read the entire content of an ELF section into a string
8886
def getSectionContent(size, offset, filename):
@@ -131,7 +129,10 @@ def extract_section_darwin(inputFile):
131129
# os independent abstraction (*nix version)
132130
#analagous procedure for linux (relying on getSectionSizeAndOffset and getSectionContent)
133131
def extract_section_linux(inputFile):
134-
(sectionSize, sectionOffset) = getSectionSizeAndOffset(elfSectionName, inputFile)
132+
val = getSectionSizeAndOffset(elfSectionName, inputFile)
133+
if val is None:
134+
return []
135+
(sectionSize, sectionOffset) = val
135136
content = getSectionContent(sectionSize, sectionOffset, inputFile)
136137
contents = content.split('\n')
137138
if not contents:
@@ -198,7 +199,7 @@ def handleArchive(inputFile, outputFile, arCmd, fileType, extractor, llvmArchive
198199
arP = Popen(arCmd)
199200
except OSError as e:
200201
if e.errno == 2:
201-
errorMsg = "Your llvm-ar doesn't seem to be easy to find.\nEither install it or use the -a llvmArchiver option."
202+
errorMsg = "Your ar doesn't seem to be easy to find.\n"
202203
else:
203204
errorMsg = "OS error({0}): {1}".format(e.errno, e.strerror)
204205
logging.error(errorMsg)
@@ -240,7 +241,7 @@ def handleArchive(inputFile, outputFile, arCmd, fileType, extractor, llvmArchive
240241

241242
#write the manifest file if asked for
242243
if manifestFlag:
243-
manifestFile = '{0}.occcam.manifest'.format(inputFile)
244+
manifestFile = '{0}.llvm.manifest'.format(inputFile)
244245
with open(manifestFile, 'w') as output:
245246
for f in bitCodeFiles:
246247
output.write('{0}\n'.format(f))

0 commit comments

Comments
 (0)