brintos

brintos / llvm-project-archived public Read only

0
0
Text · 10.8 KiB · 49b8f0d Raw
271 lines · plain
1## Test tools are able to dump different types of notes.2 3# RUN: yaml2obj --docnum=1 %s -o %t1.so4# RUN: llvm-readelf --notes %t1.so | FileCheck %s --check-prefix=GNU --strict-whitespace --match-full-lines5# RUN: llvm-readobj --notes %t1.so | FileCheck %s --check-prefix=LLVM6# RUN: llvm-objcopy --strip-sections %t1.so %t1.stripped.so7# RUN: llvm-readelf --notes %t1.stripped.so | FileCheck %s --check-prefix=GNU-STRIPPED --strict-whitespace --match-full-lines8# RUN: llvm-readobj --notes %t1.stripped.so | FileCheck %s --check-prefix=LLVM-STRIPPED9 10#      GNU:Displaying notes found in: .note.ABI-tag11# GNU-NEXT:  Owner                Data size 	Description12# GNU-NEXT:  GNU                  0x00000010	NT_GNU_ABI_TAG (ABI version tag)13# GNU-NEXT:    OS: Linux, ABI: 2.6.3214# GNU-EMPTY:15# GNU-NEXT:Displaying notes found in: .note.gnu.build-id16# GNU-NEXT:  Owner                Data size 	Description17# GNU-NEXT:  GNU                  0x00000010	NT_GNU_BUILD_ID (unique build ID bitstring)18# GNU-NEXT:    Build ID: 4fcb712aa6387724a9f465a32cd8c14b19# GNU-EMPTY:20# GNU-NEXT:Displaying notes found in: .note.gnu.gold-version21# GNU-NEXT:  Owner                Data size 	Description22# GNU-NEXT:  GNU                  0x00000009	NT_GNU_GOLD_VERSION (gold version)23# GNU-NEXT:    Version: gold 1.1124# GNU-EMPTY:25# GNU-NEXT:Displaying notes found in: .note.gnu.unknown26# GNU-NEXT:  Owner                Data size 	Description27# GNU-NEXT:  GNU                  0x00000004	Unknown note type: (0x0000abcd)28# GNU-NEXT:   description data: 61 62 63 6429# GNU-EMPTY:30 31# LLVM:      NoteSections [32# LLVM-NEXT:   NoteSection {33# LLVM-NEXT:     Name: .note.ABI-tag34# LLVM-NEXT:     Offset: 0x7835# LLVM-NEXT:     Size: 0x2036# LLVM-NEXT:     Notes [37# LLVM-NEXT:     {38# LLVM-NEXT:       Owner: GNU39# LLVM-NEXT:       Data size: 0x1040# LLVM-NEXT:       Type: NT_GNU_ABI_TAG (ABI version tag)41# LLVM-NEXT:       OS: Linux42# LLVM-NEXT:       ABI: 2.6.3243# LLVM-NEXT:     }44# LLVM-NEXT:    ]45# LLVM-NEXT:   }46# LLVM-NEXT:   NoteSection {47# LLVM-NEXT:     Name: .note.gnu.build-id48# LLVM-NEXT:     Offset: 0x9849# LLVM-NEXT:     Size: 0x2050# LLVM-NEXT:     Notes [51# LLVM-NEXT:     {52# LLVM-NEXT:       Owner: GNU53# LLVM-NEXT:       Data size: 0x1054# LLVM-NEXT:       Type: NT_GNU_BUILD_ID (unique build ID bitstring)55# LLVM-NEXT:       Build ID: 4fcb712aa6387724a9f465a32cd8c14b56# LLVM-NEXT:     }57# LLVM-NEXT:    ]58# LLVM-NEXT:   }59# LLVM-NEXT:   NoteSection {60# LLVM-NEXT:     Name: .note.gnu.gold-version61# LLVM-NEXT:     Offset: 0xB862# LLVM-NEXT:     Size: 0x1C63# LLVM-NEXT:     Notes [64# LLVM-NEXT:     {65# LLVM-NEXT:       Owner: GNU66# LLVM-NEXT:       Data size: 0x967# LLVM-NEXT:       Type: NT_GNU_GOLD_VERSION (gold version)68# LLVM-NEXT:       Version: gold 1.1169# LLVM-NEXT:     }70# LLVM-NEXT:    ]71# LLVM-NEXT:   }72# LLVM-NEXT:   NoteSection {73# LLVM-NEXT:     Name: .note.gnu.unknown74# LLVM-NEXT:     Offset: 0xD475# LLVM-NEXT:     Size: 0x1476# LLVM-NEXT:     Notes [77# LLVM-NEXT:     {78# LLVM-NEXT:       Owner: GNU79# LLVM-NEXT:       Data size: 0x480# LLVM-NEXT:       Type: Unknown (0x0000abcd)81# LLVM-NEXT:       Description data (82# LLVM-NEXT:         0000: 61626364                             |abcd|83# LLVM-NEXT:       )84# LLVM-NEXT:     }85# LLVM-NEXT:    ]86# LLVM-NEXT:   }87# LLVM-NEXT: ]88 89## Note: the section name is <?> here because the section header table is not present.90# LLVM-STRIPPED:      NoteSections [91# LLVM-STRIPPED-NEXT:   NoteSection {92# LLVM-STRIPPED-NEXT:     Name: <?>93# LLVM-STRIPPED-NEXT:     Offset: 0x7894# LLVM-STRIPPED-NEXT:     Size: 0x2095# LLVM-STRIPPED-NEXT:     Notes [96# LLVM-STRIPPED-NEXT:     {97# LLVM-STRIPPED-NEXT:       Owner: GNU98# LLVM-STRIPPED-NEXT:       Data size: 0x1099# LLVM-STRIPPED-NEXT:       Type: NT_GNU_BUILD_ID (unique build ID bitstring)100# LLVM-STRIPPED-NEXT:       Build ID: 4fcb712aa6387724a9f465a32cd8c14b101# LLVM-STRIPPED-NEXT:     }102# LLVM-STRIPPED-NEXT:    ]103# LLVM-STRIPPED-NEXT:   }104# LLVM-STRIPPED-NEXT: ]105 106## Note: offset and length printed instead of "found in: .note.gnu.build-id"107## because the section header table is not present.108#      GNU-STRIPPED:Displaying notes found at file offset 0x00000078 with length 0x00000020:109# GNU-STRIPPED-NEXT:  Owner                Data size 	Description110# GNU-STRIPPED-NEXT:  GNU                  0x00000010	NT_GNU_BUILD_ID (unique build ID bitstring)111# GNU-STRIPPED-NEXT:    Build ID: 4fcb712aa6387724a9f465a32cd8c14b112 113--- !ELF114FileHeader:115  Class:      ELFCLASS64116  Data:       ELFDATA2LSB117  Type:       ET_EXEC118  EPhEntSize: [[PHENTSIZE=<none>]]119  EShNum:     [[SHNUM=<none>]]120Sections:121  - Name:         .note.ABI-tag122    Type:         SHT_NOTE123    AddressAlign: 0x0000000000000004124    Content:      040000001000000001000000474E550000000000020000000600000020000000125  - Name:         .note.gnu.build-id126    Type:         SHT_NOTE127    Flags:        [ SHF_ALLOC ]128    Address:      0x0000000000400120129    AddressAlign: 0x0000000000000004130    Content:      040000001000000003000000474E55004FCB712AA6387724A9F465A32CD8C14B131  - Name:         .note.gnu.gold-version132    Type:         SHT_NOTE133    AddressAlign: 0x0000000000000004134    Content:      040000000900000004000000474E5500676F6C6420312E3131000000135  - Name:         .note.gnu.unknown136    Type:         SHT_NOTE137    AddressAlign: 0x0000000000000004138    Content:      0400000004000000cdab0000474E550061626364139ProgramHeaders:140  - Type:     PT_NOTE141    FileSize: 0x20142    FirstSec: .note.gnu.build-id143    LastSec:  .note.gnu.build-id144 145## Test tools report an error if a note section has an invalid offset146## that goes past the end of file.147 148# RUN: yaml2obj --docnum=2 -DSHOFFSET=0xffff0000 %s -o %t2.so149# RUN: llvm-readelf --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s --check-prefix=ERR1-GNU150# RUN: llvm-readobj --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s --check-prefix=ERR1-LLVM151 152# ERR1-GNU:      Displaying notes found in: .note153# ERR1-GNU-NEXT:   Owner                Data size        Description154# ERR1-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0xffff0000) or size (0x0)155# ERR1-GNU-EMPTY:156 157# ERR1-LLVM:      NoteSections [158# ERR1-LLVM-NEXT:   NoteSection {159# ERR1-LLVM-NEXT:     Name:   .note160# ERR1-LLVM-NEXT:     Offset: 0xFFFF0000161# ERR1-LLVM-NEXT:     Size:   0x0162# ERR1-LLVM-NEXT:     Notes [163# ERR1-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0xffff0000) or size (0x0)164# ERR1-LLVM-NEXT:    ]165# ERR1-LLVM-NEXT:   }166# ERR1-LLVM-NEXT: ]167 168--- !ELF169FileHeader:170  Class: ELFCLASS64171  Data:  ELFDATA2LSB172  Type:  ET_EXEC173Sections:174  - Name:     .note175    Type:     SHT_NOTE176    Notes:    []177    ShOffset: [[SHOFFSET=<none>]]178    ShSize:   [[SHSIZE=<none>]]179 180## Test tools report an error if a note section has invalid size181## that goes past the end of file.182 183# RUN: yaml2obj --docnum=2 -DSHSIZE=0xffff0000 %s -o %t3.so184# RUN: llvm-readelf --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s --check-prefix=ERR2-GNU185# RUN: llvm-readobj --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s --check-prefix=ERR2-LLVM186 187# ERR2-GNU:      Displaying notes found in: .note188# ERR2-GNU-NEXT:   Owner                Data size        Description189# ERR2-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0x40) or size (0xffff0000)190# ERR2-GNU-EMPTY:191 192# ERR2-LLVM:      NoteSections [193# ERR2-LLVM-NEXT:   NoteSection {194# ERR2-LLVM-NEXT:     Name: .note195# ERR2-LLVM-NEXT:     Offset: 0x40196# ERR2-LLVM-NEXT:     Size: 0xFFFF0000197# ERR2-LLVM-NEXT:     Notes [198# ERR2-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0x40) or size (0xffff0000)199# ERR2-LLVM-NEXT:    ]200# ERR2-LLVM-NEXT:   }201# ERR2-LLVM-NEXT: ]202 203## Test tools report an error if a note program header has an invalid offset that204## goes past the end of file.205 206# RUN: yaml2obj --docnum=3 -DPHOFFSET=0xffff0000 %s -o %t4.so207# RUN: llvm-readelf --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s --check-prefix=ERR3-GNU208# RUN: llvm-readobj --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s --check-prefix=ERR3-LLVM209 210# ERR3-GNU:      Displaying notes found at file offset 0xffff0000 with length 0x00000000:211# ERR3-GNU-NEXT:   Owner                Data size        Description212# ERR3-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE segment with index 0: invalid offset (0xffff0000) or size (0x0)213# ERR3-GNU-NOT: {{.}}214 215# ERR3-LLVM:      NoteSections [216# ERR3-LLVM-NEXT:   NoteSection {217# ERR3-LLVM-NEXT:     Name: <?>218# ERR3-LLVM-NEXT:     Offset: 0xFFFF0000219# ERR3-LLVM-NEXT:     Size: 0x0220# ERR3-LLVM-NEXT:     Notes [221# ERR3-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE segment with index 0: invalid offset (0xffff0000) or size (0x0)222# ERR3-LLVM-NEXT:    ]223# ERR3-LLVM-NEXT:   }224# ERR3-LLVM-NEXT: ]225 226--- !ELF227FileHeader:228  Class: ELFCLASS64229  Data:  ELFDATA2LSB230  Type:  ET_CORE231ProgramHeaders:232  - Type:     PT_NOTE233    Offset:   [[PHOFFSET=<none>]]234    FileSize: [[PHFILESIZE=<none>]]235 236## Test tools report an error if a note program header has an invalid size that237## goes past the end of file.238 239# RUN: yaml2obj --docnum=3 -DPHFILESIZE=0xffff0000 %s -o %t5.so240# RUN: llvm-readelf --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so %s --check-prefix=ERR4-GNU241# RUN: llvm-readobj --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so %s --check-prefix=ERR4-LLVM242 243# ERR4-GNU:      Displaying notes found at file offset 0x00000000 with length 0xffff0000:244# ERR4-GNU-NEXT:   Owner                Data size        Description245# ERR4-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE segment with index 0: invalid offset (0x0) or size (0xffff0000)246# ERR4-GNU-EMPTY:247 248# ERR4-LLVM:      NoteSections [249# ERR4-LLVM-NEXT:   NoteSection {250# ERR4-LLVM-NEXT:     Name: <?>251# ERR4-LLVM-NEXT:     Offset: 0x0252# ERR4-LLVM-NEXT:     Size: 0xFFFF0000253# ERR4-LLVM-NEXT:     Notes [254# ERR4-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE segment with index 0: invalid offset (0x0) or size (0xffff0000)255# ERR4-LLVM-NEXT:    ]256# ERR4-LLVM-NEXT:   }257# ERR4-LLVM-NEXT: ]258 259## Check we report a warning when we are unable to locate the PT_NOTE260## segment because of broken program headers.261# RUN: yaml2obj --docnum=1 -DPHENTSIZE=1 -DSHNUM=0 %s -o %t6.so262# RUN: llvm-readelf --notes %t6.so 2>&1 | FileCheck %s -DFILE=%t6.so --check-prefix=PHENTSIZE-WARN-GNU263# RUN: llvm-readobj --notes %t6.so 2>&1 | FileCheck %s -DFILE=%t6.so --check-prefix=PHENTSIZE-WARN-LLVM264 265# PHENTSIZE-WARN-GNU: warning: '[[FILE]]': unable to read program headers to locate the PT_DYNAMIC segment: invalid e_phentsize: 1266# PHENTSIZE-WARN-GNU: warning: '[[FILE]]': unable to read program headers to locate the PT_NOTE segment: invalid e_phentsize: 1267 268# PHENTSIZE-WARN-LLVM:      NoteSections [269# PHENTSIZE-WARN-LLVM-NEXT: warning: '[[FILE]]': unable to read program headers to locate the PT_NOTE segment: invalid e_phentsize: 1270# PHENTSIZE-WARN-LLVM-NEXT: ]271