[PATCH] D147823: [clang-repl] Reduce dynamic-library.cpp test to only load shared library

Han Zhu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 10 12:33:49 PDT 2023


zhuhan0 added a comment.

This doesn't work. The test would fail with

  error: libdynamic-library-test.so: ELF load command address/offset not properly aligned

I first used obj2yaml to convert `libdynamic-library-test.so` to YAML, and then the test uses yaml2obj to convert it back. But it looks like yaml2obj could not generate a loadable shared library. The input library's first load offset starts at 0x000:

  LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**12
       filesz 0x00000000000004f4 memsz 0x00000000000004f4 flags r--

It contains a padding section before the first real section .dynsym:

  Sections:
  Idx Name                  Size     VMA              Type
    0                       00000000 0000000000000000
    1 .dynsym               000000a8 0000000000000238

But in the output library of yaml2obj, the first load offset does not start at 0x000 but with the start of .dynsym 0x238

  LOAD off    0x0000000000000238 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**12
       filesz 0x00000000000002bc memsz 0x00000000000002bc flags r--

It's not aligned by 0x1000 and therefore it failed to load.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147823/new/

https://reviews.llvm.org/D147823



More information about the cfe-commits mailing list