diff --git a/llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-relocs.test b/llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-relocs.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-relocs.test @@ -0,0 +1,61 @@ +## Show that --disassemble + --dynamic-reloc prints relocations inline and +## does not dump the relocation sections. + +# RUN: yaml2obj %s -o %t.o +# RUN: llvm-objdump %t.o --dynamic-reloc | \ +# RUN: FileCheck %s --check-prefix=DYN-RELOC --implicit-check-not=Disassembly +# RUN: llvm-objdump %t.o --disassemble --dynamic-reloc | \ +# RUN: FileCheck %s --implicit-check-not="DYNAMIC RELOCATION RECORDS" + +# DYN-RELOC: DYNAMIC RELOCATION RECORDS + +# CHECK: Disassembly of section .text: +# CHECK: e8 55 00 00 00 callq 85 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .rela.plt + Type: SHT_RELA + Flags: [ SHF_ALLOC ] + Address: 0x0000000000000400 + Link: .dynsym + Info: .got.plt + Relocations: + - Offset: 0x0000000000003838 + Symbol: bar + Type: R_X86_64_JUMP_SLOT + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000001520 + Content: 488D3DF1220000488D05EA2200004839F87415488B05BE1200004885C07409FFE00F1F8000000000C30F1F8000000000488D3DC1220000488D35BA2200004829FE48C1FE034889F048C1E83F4801C648D1FE7414488B05851200004885C07408FFE0660F1F440000C30F1F8000000000803DA922000000752F5548833D66120000004889E5740C488B3D62220000E87D000000E868FFFFFFC60581220000015DC30F1F8000000000C30F1F8000000000E97BFFFFFFCCCCCCCCCCCCCCCCCCCCCC554889E5B000E855000000C3 + - Name: .plt + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000001620 + Content: FF35FA210000FF25FC2100000F1F4000FF25FA2100006800000000E9E0FFFFFFFF25F22100006801000000E9D0FFFFFF + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_WRITE, SHF_ALLOC ] + Link: .dynstr + EntSize: 0x0000000000000010 + Entries: + - Tag: DT_JMPREL + Value: 0x0000000000000400 + - Tag: DT_NULL + Value: 0x0000000000000000 + - Name: .got.plt + Type: SHT_PROGBITS +DynamicSymbols: + - Name: bar + Binding: STB_GLOBAL + - Name: foo + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x00000000000015E0 diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -2085,7 +2085,7 @@ disassembleObject(O, Relocations); if (Relocations && !Disassemble) printRelocations(O); - if (DynamicRelocations) + if (DynamicRelocations && !Disassemble) printDynamicRelocations(O); if (PrivateHeaders || FirstPrivateHeader) printPrivateFileHeaders(O, FirstPrivateHeader);