[PATCH] D66485: [Clang][Bundler] Use llvm-objcopy for creating fat object files
Sergey Dmitriev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 26 09:52:39 PDT 2019
sdmitriev marked an inline comment as done.
sdmitriev added inline comments.
================
Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:485
+ "=" + InputFileNames[I]));
+ ObjcopyArgs.push_back(InputFileNames[HostInputIndex]);
+ ObjcopyArgs.push_back(OutputFileNames.front());
----------------
ABataev wrote:
> As I understand, the resulting object file has the same structure as before? And we still can get an access to the host object file using standard programs, like readelf, objdump, etc.?
Yes, the structure is the same. The only difference is in the section flags that contain device objects - such sections used to have ALLOC attribute, but they do not have it now which I believe is a good think.
That is what we had earlier:
```
bash-4.2$ cat y.c
#pragma omp declare target
void foo() {}
#pragma omp end declare target
bash-4.2$ clang -fopenmp -fopenmp-targets=x86_64-pc-linux-gnu -c y.c
bash-4.2$ objdump -h y.o
y.o: file format elf64-x86-64
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000008 0000000000000000 0000000000000000 00000040 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .text.startup 00000010 0000000000000000 0000000000000000 00000050 2**4
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
2 __CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu 000003f8 0000000000000000 0000000000000000 00000060 2**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 __CLANG_OFFLOAD_BUNDLE__host-x86_64-unknown-linux-gnu 00000630 0000000000000000 0000000000000000 00000460 2**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .eh_frame 00000058 0000000000000000 0000000000000000 00000a90 2**3
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
5 .init_array.0 00000008 0000000000000000 0000000000000000 00000ae8 2**3
CONTENTS, ALLOC, LOAD, RELOC, DATA
6 .comment 0000006a 0000000000000000 0000000000000000 00000af0 2**0
CONTENTS, READONLY
7 .note.GNU-stack 00000000 0000000000000000 0000000000000000 00000b5a 2**0
CONTENTS, READONLY
8 .llvm_addrsig 00000002 0000000000000000 0000000000000000 00000b5a 2**0
CONTENTS, READONLY, EXCLUDE
bash-4.2$
```
And here is what we have with this patch:
```
bash-4.2$ clang -fopenmp -fopenmp-targets=x86_64-pc-linux-gnu -c y.c
bash-4.2$ objdump -h y.o
y.o: file format elf64-x86-64
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000006 0000000000000000 0000000000000000 00000040 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .text.startup 00000010 0000000000000000 0000000000000000 00000050 2**4
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
2 .init_array.0 00000008 0000000000000000 0000000000000000 00000060 2**3
CONTENTS, ALLOC, LOAD, RELOC, DATA
3 .comment 0000006a 0000000000000000 0000000000000000 00000068 2**0
CONTENTS, READONLY
4 .note.GNU-stack 00000000 0000000000000000 0000000000000000 000000d2 2**0
CONTENTS, READONLY
5 .eh_frame 00000058 0000000000000000 0000000000000000 000000d8 2**3
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
6 .llvm_addrsig 00000002 0000000000000000 0000000000000000 00000238 2**0
CONTENTS, READONLY, EXCLUDE
7 __CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu 000003f8 0000000000000000 0000000000000000 00000353 2**0
CONTENTS, READONLY
8 __CLANG_OFFLOAD_BUNDLE__host-x86_64-unknown-linux-gnu 00000630 0000000000000000 0000000000000000 0000074b 2**0
CONTENTS, READONLY
bash-4.2$
```
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66485/new/
https://reviews.llvm.org/D66485
More information about the cfe-commits
mailing list