<div dir="ltr"><a class="gmail_plusreply" id="plusReplyChip-1" href="mailto:maskray@google.com" tabindex="-1">+Fangrui Song</a> <br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 15, 2021 at 2:57 PM Tomasz Gajc via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div><div>i'm trying to dig issue with building systemd-boot EFI images with llvm/clang and linking with llvm/lld. In general building and linking process works and i get my final objects. Unfortunately these EFI images does not boot system. I noticed that .efi image is missing PE/COFF relocations.</div><div>When i changed linker to ld.bfd, voila everything is fine and final efi image does boot system and have needed relocs. I tried all the ld.lld options related to relocations, but still no success.</div><div>Thanks for your help.</div><div><br></div><div>Below you can find diff between two objdumps.</div><div><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:11.9px;margin-top:0px;padding:16px;overflow:auto;line-height:1.45;border-radius:6px;color:rgb(36,41,46);margin-bottom:0px"><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:11.9px;padding:0px;margin:0px;background:initial;border-radius:6px;word-break:normal;border:0px;display:inline;overflow:visible;line-height:inherit">[root@tpg-latitude5490 /]# cat bootx.linkers.diff 
--- bootx.BFD   2021-03-14 23:33:41.687446710 +0100
+++ bootx.LLD   2021-03-14 23:33:58.037519874 +0100
@@ -1,11 +1,12 @@
 
-systemd-bootx64.efi.BFD:     file format pei-x86-64
-systemd-bootx64.efi.BFD
-architecture: i386:x86-64, flags 0x00000133:
-HAS_RELOC, EXEC_P, HAS_SYMS, HAS_LOCALS, D_PAGED
-start address 0x0000000000003000
+systemd-bootx64.efi.LLD:     file format pei-x86-64
+systemd-bootx64.efi.LLD
+architecture: i386:x86-64, flags 0x00000132:
+EXEC_P, HAS_SYMS, HAS_LOCALS, D_PAGED
+start address 0x0000000000004000
 
-Characteristics 0x206
+Characteristics 0x207
+       relocations stripped
        executable
        line numbers stripped
        debugging information removed
@@ -14,11 +15,11 @@
 Magic                  020b    (PE32+)
 MajorLinkerVersion     2
 MinorLinkerVersion     36
-SizeOfCode             0000000000010000
-SizeOfInitializedData  0000000000006000
+SizeOfCode             000000000000f600
+SizeOfInitializedData  0000000000005e00
 SizeOfUninitializedData        0000000000000000
-AddressOfEntryPoint    0000000000003000
-BaseOfCode             0000000000003000
+AddressOfEntryPoint    0000000000004000
+BaseOfCode             0000000000004000
 ImageBase              0000000000000000
 SectionAlignment       00001000
 FileAlignment          00000200
@@ -29,9 +30,9 @@
 MajorSubsystemVersion  0
 MinorSubsystemVersion  0
 Win32Version           00000000
-SizeOfImage            0001c000
-SizeOfHeaders          00000400
-CheckSum               00022f3d
+SizeOfImage            0001b000
+SizeOfHeaders          00000370
+CheckSum               0001b531
 Subsystem              0000000a        (EFI application)
 DllCharacteristics     00000000
 SizeOfStackReserve     0000000000000000
@@ -47,7 +48,7 @@
 Entry 2 0000000000000000 00000000 Resource Directory [.rsrc]
 Entry 3 0000000000000000 00000000 Exception Directory [.pdata]
 Entry 4 0000000000000000 00000000 Security Directory
-Entry 5 0000000000013000 0000000a Base Relocation Directory [.reloc]
+Entry 5 0000000000000000 00000000 Base Relocation Directory [.reloc]
 Entry 6 0000000000000000 00000000 Debug Directory
 Entry 7 0000000000000000 00000000 Description Directory
 Entry 8 0000000000000000 00000000 Special Directory
@@ -59,367 +60,358 @@
 Entry e 0000000000000000 00000000 CLR Runtime Header
 Entry f 0000000000000000 00000000 Reserved
 
-
-PE File Base Relocations (interpreted .reloc section contents)
-
-Virtual Address: 00004770 Chunk size 10 (0xa) Number of fixups 1
-       reloc    0 offset    0 [4770] ABSOLUTE
-
 Sections:
 Idx Name          Size      VMA               LMA               File off  Algn
-  0 .text         0000ff20  0000000000003000  0000000000003000  00000400  2**4
-                  CONTENTS, ALLOC, LOAD, READONLY, CODE
-  1 .reloc        0000000a  0000000000013000  0000000000013000  00010400  2**0
+  0 .rela.dyn     00000fa8  0000000000000170  0000000000000170  00000370  2**3
                   CONTENTS, ALLOC, LOAD, READONLY, DATA
-  2 .data         00004460  0000000000014000  0000000000014000  00010600  2**5
+  1 .text         0000f510  0000000000004000  0000000000004000  00001400  2**4
+                  CONTENTS, ALLOC, LOAD, READONLY, CODE
+  2 .data         00004578  0000000000014000  0000000000014000  00010a00  2**5
                   CONTENTS, ALLOC, LOAD, DATA
-  3 .dynamic      000000f0  0000000000019000  0000000000019000  00014c00  2**3
+  3 .dynamic      000000a0  0000000000019000  0000000000019000  00015000  2**3
                   CONTENTS, ALLOC, LOAD, DATA
-  4 .rela         00000fa8  000000000001a000  000000000001a000  00014e00  2**3
-                  CONTENTS, ALLOC, LOAD, READONLY, DATA
-  5 .dynsym       000004e0  000000000001b000  000000000001b000  00015e00  2**3
+  4 .dynsym       00000450  000000000001a000  000000000001a000  00015200  2**3
                   CONTENTS, ALLOC, LOAD, READONLY, DATA</code></pre></div><div><br></div><div><br></div>1. [systemd issue] - <a href="https://github.com/systemd/systemd/issues/19005" target="_blank">https://github.com/systemd/systemd/issues/19005</a><br></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>