@@ -383,23 +383,42 @@ def symbols_from(object_file):
383383 if proc .returncode :
384384 logging .error ("`%s` failed. Output:\n %s" , " " .join (cmd ), proc_output )
385385 exit (1 )
386- pat = re .compile (r"(?P<addr>[^\s]+)\s+"
387- r"(?P<flags>[lgu! ][w ][C ][W ][Ii ][Dd ][FfO ])\s+"
388- r"(?P<section>[^\s]+)\s+"
389- r"(?P<size>[0-9a-f]+)\s+"
386+ # example: "[ 6](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 fred"
387+ pat = re .compile (r"\[\s*\d+\]" # number of the entry
388+ r"\(sec\s+-?\d+\)" # section number
389+ r"\(fl\s+0x[\da-f]+\)" # flag bits
390+ r"\(ty\s+\d+\)" # type
391+ r"\(scl\s+\d+\)\s+" # storage class
392+ r"\(nx\s+\d+\)\s+" # number of auxiliary entries
393+ r"0x(?P<addr>[\da-f]+)\s+"
394+ r"(?P<name>[^\s]*)" # Can be empty!
395+ )
396+ # example: "00000000 g .text 00000000 fred"
397+ pat_elf = re .compile (r"(?P<addr>[\da-f]+)\s+"
398+ r"[lgu! ][w ][C ][W ][Ii ][Dd ][FfO ]\s+" # flags
399+ r"[^\s]+\s+" # section
400+ r"[\da-f]+\s+" # size
401+ r"(?:\.hidden\s+)?"
390402 r"(?P<name>[^\s]*)" # Can be empty!
391403 )
404+ elf_format = False
392405 matching = False
393406 ret = {}
394407 for line in proc_output .splitlines ():
395408 if not line :
396409 continue
397- if not matching and re .match ("SYMBOL TABLE:" , line ):
398- matching = True
399- continue
400410 if not matching :
411+ if re .match (r"^.+:\s+file format .*elf.*$" , line ):
412+ elf_format = True
413+ elif re .match (r"^SYMBOL TABLE:$" , line ):
414+ matching = True
415+ continue
416+ if elf_format :
417+ m = pat_elf .match (line )
418+ elif re .match (r"^File\s*$" , line ):
401419 continue
402- m = pat .match (line )
420+ else :
421+ m = pat .match (line )
403422 if not m :
404423 logging .error ("Unexpected line from `%s`:\n %s" ,
405424 " " .join (cmd ), line )
0 commit comments