This is an archive of the discontinued LLVM Phabricator instance.

[clang-repl] Reduce dynamic-library.cpp test to only load shared library
AbandonedPublic

Authored by zhuhan0 on Apr 7 2023, 4:14 PM.

Details

Summary

Follow-up to the discussion in https://reviews.llvm.org/D141824. Because the
purpose of the test is to test loading a shared library, and clang tests
traditionally have not invoked actual linking, reduce this test case to loading
a shared library only.

Diff Detail

Event Timeline

zhuhan0 created this revision.Apr 7 2023, 4:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2023, 4:14 PM
Herald added subscribers: hoy, wenlei. · View Herald Transcript
zhuhan0 requested review of this revision.Apr 7 2023, 4:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2023, 4:14 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Could we use yaml2obj instead of uploading the binary? I see other tests using it.

zhuhan0 updated this revision to Diff 512222.Apr 10 2023, 12:27 PM

Try with yaml2obj.

zhuhan0 updated this revision to Diff 512223.Apr 10 2023, 12:28 PM

Remove .so file.

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.

Could we disable the test on that platform?