1*99cec7ffSAlex Bradbury// REQUIRES: system-linux, native, python 2f1e28862SGreg Clayton 3f1e28862SGreg Clayton// This test verifies that loading an ELF file from memory works and the new 4f1e28862SGreg Clayton// features that were added when loading from memory work like: 5f1e28862SGreg Clayton// - Loading the .dynamic section from the PT_DYNAMIC since ELF files loaded 6f1e28862SGreg Clayton// from memory don't have the section headers available. 7f1e28862SGreg Clayton// This test will make a simple executable that: 8f1e28862SGreg Clayton// - links against libc 9f1e28862SGreg Clayton// - runs and stops at a breakpoint 10f1e28862SGreg Clayton// - create a memory ELF file 11f1e28862SGreg Clayton// - verify that "image dump objfile" will dump the dynamic section of the 12f1e28862SGreg Clayton// memory elf file and find the .dynamic string table. 13f1e28862SGreg Clayton 14f1e28862SGreg Clayton// RUN: %clang_host %p/Inputs/memory-elf.cpp -g -O0 -o %t 15f1e28862SGreg Clayton 16f1e28862SGreg Clayton// RUN: %lldb %t -b \ 17f1e28862SGreg Clayton// RUN: -o "b main" \ 18f1e28862SGreg Clayton// RUN: -o "run" \ 19f1e28862SGreg Clayton// RUN: -o "script real_module = lldb.target.module[0]" \ 20f1e28862SGreg Clayton// RUN: -o "script base_addr = real_module.GetObjectFileHeaderAddress().GetLoadAddress(lldb.target)" \ 21f1e28862SGreg Clayton// RUN: -o "script mem_module = lldb.SBModule(lldb.process, base_addr)" \ 22f1e28862SGreg Clayton// RUN: -o "script target2 = lldb.debugger.CreateTarget('')" \ 23f1e28862SGreg Clayton// RUN: -o "script target2.AddModule(mem_module)" \ 24f1e28862SGreg Clayton// RUN: -o "target select 1" \ 25f1e28862SGreg Clayton// RUN: -o "image dump objfile" \ 26f1e28862SGreg Clayton// RUN: | FileCheck %s --check-prefix=MAIN --dump-input=always 27f1e28862SGreg Clayton// MAIN: (lldb) image dump objfile 28f1e28862SGreg Clayton// MAIN: Dumping headers for 1 module(s). 29f1e28862SGreg Clayton// MAIN: ObjectFileELF, file = '', arch = {{.*, addr = 0x[0-9a-f]+}} 30f1e28862SGreg Clayton// MAIN: ELF Header 31f1e28862SGreg Clayton 32f1e28862SGreg Clayton// Make sure we find the program headers and see a PT_DYNAMIC entry. 33f1e28862SGreg Clayton// MAIN: Program Headers 34f1e28862SGreg Clayton// MAIN: ] PT_DYNAMIC 35f1e28862SGreg Clayton 36f1e28862SGreg Clayton// Make sure we see some sections created from the program headers 37f1e28862SGreg Clayton// MAIN: SectID 38f1e28862SGreg Clayton// MAIN: PT_LOAD[0] 39f1e28862SGreg Clayton 40f1e28862SGreg Clayton// Ensure we find some dependent modules as won't find these if we aren't able 41f1e28862SGreg Clayton// to load the .dynamic section from the PT_DYNAMIC program header. 42f1e28862SGreg Clayton// MAIN: Dependent Modules: 43f1e28862SGreg Clayton 44f1e28862SGreg Clayton// Check for the .dynamic dump and ensure we find all dynamic entries that are 45f1e28862SGreg Clayton// required to be there and needed to get the .dynstr section and the symbol 46f1e28862SGreg Clayton// table, and the DT_DEBUG entry to find the list of shared libraries. 47f1e28862SGreg Clayton// MAIN: .dynamic: 48f1e28862SGreg Clayton// Make sure we found the .dynstr section by checking for valid strings after NEEDED 49f1e28862SGreg Clayton// MAIN-DAG: NEEDED {{0x[0-9a-f]+ ".*libc.*"}} 50f1e28862SGreg Clayton// MAIN-DAG: STRTAB {{0x[0-9a-f]+}} 51f1e28862SGreg Clayton// MAIN-DAG: SYMTAB {{0x[0-9a-f]+}} 52f1e28862SGreg Clayton// MAIN-DAG: STRSZ {{0x[0-9a-f]+}} 53f1e28862SGreg Clayton// MAIN-DAG: SYMENT {{0x[0-9a-f]+}} 54f1e28862SGreg Clayton// MAIN-DAG: DEBUG {{0x[0-9a-f]+}} 55f1e28862SGreg Clayton// MAIN: NULL {{0x[0-9a-f]+}} 56