Skip to content

Commit 13ba171

Browse files
committed
Fix support for shared libraries
The file type fingerprinting code could not deal with shared libraries. Added the necessary patterns. Also, resolve symbolic links before checking the file type.
1 parent e236212 commit 13ba171

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

driver/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,13 @@ def getFileType(cls, fileName):
218218
# the type of file we are looking at.
219219
# Maybe we should use python-magic instead?
220220

221-
fileP = Popen(['file',fileName], stdout=PIPE)
221+
fileP = Popen(['file',os.path.realpath(fileName)], stdout=PIPE)
222222
output = fileP.communicate()[0]
223223
output = output.decode()
224224
if 'ELF' in output and 'executable' in output:
225225
return cls.EXECUTABLE
226+
elif 'ELF' in output and 'shared' in output:
227+
return cls.SHARED
226228
elif 'current ar archive' in output:
227229
return cls.ARCHIVE
228230
elif 'ELF' in output and 'relocatable' in output:
@@ -232,7 +234,7 @@ def getFileType(cls, fileName):
232234

233235
@classmethod
234236
def init(cls):
235-
for (index, name) in enumerate(('UNKNOWN', 'EXECUTABLE', 'OBJECT', 'ARCHIVE')):
237+
for (index, name) in enumerate(('UNKNOWN', 'EXECUTABLE', 'OBJECT', 'ARCHIVE', 'SHARED')):
236238
setattr(cls, name, index)
237239
cls.revMap[index] = name
238240

extract-bc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def main(args):
254254
ft = FileType.getFileType(inputFile)
255255
logging.debug('Detected file type is {0}'.format(FileType.revMap[ft]))
256256

257-
if ft == FileType.EXECUTABLE:
257+
if ft == FileType.EXECUTABLE or ft == FileType.SHARED:
258258
logging.info('Generating LLVM Bitcode module')
259259
return handleExecutable(inputFile, llvmLinker, outputFile )
260260
elif ft == FileType.ARCHIVE:

0 commit comments

Comments
 (0)