[Bug 1664725] [NEW] Can't link crt0-efi-x86_64.o to create an EFI application

Donald A. Dade donald.dade at gmail.com
Tue Feb 14 21:36:32 UTC 2017


Public bug reported:

$ uname -a
Linux x6 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -rd
Description:    Ubuntu 16.04.2 LTS
Release:        16.04

$ apt-cache policy gnu-efi
gnu-efi:
  Installed: 3.0.2-1ubuntu1
  Candidate: 3.0.2-1ubuntu1
  Version table:
 *** 3.0.2-1ubuntu1 500
        500 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status

$ make
ld -nostdlib -znocombreloc -T /usr/lib/elf_x86_64_efi.lds -shared -Bsymbolic -L /usr/lib -L /usr/lib /usr/lib/crt0-efi-x86_64.o  main.o -o hello.so -lefi -lgnuefi
ld: /usr/lib/crt0-efi-x86_64.o: relocation R_X86_64_PC32 against undefined symbol `efi_main' can not be used when making a shared object; recompile with -fPIC

I expected the link to succeed, but it fails with the above error.

Sure enough, the object code has PC32 relocation records:

$ readelf -r /usr/lib/crt0-efi-x86_64.o
Relocation section '.rela.text' at offset 0x238 contains 4 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000000009  000900000002 R_X86_64_PC32     0000000000000000 ImageBase - 4
000000000010  000a00000002 R_X86_64_PC32     0000000000000000 _DYNAMIC - 4
000000000019  000b00000002 R_X86_64_PC32     0000000000000000 _relocate - 4
000000000020  000c00000002 R_X86_64_PC32     0000000000000000 efi_main - 4

Relocation section '.rela.reloc' at offset 0x298 contains 1 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000000000  000200000002 R_X86_64_PC32     0000000000000000 .data + 0

** Affects: gnu-efi (Ubuntu)
     Importance: Undecided
         Status: New

** Package changed: sbsigntool (Ubuntu) => gnu-efi (Ubuntu)

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to sbsigntool in Ubuntu.
https://bugs.launchpad.net/bugs/1664725

Title:
  Can't link crt0-efi-x86_64.o to create an EFI application

Status in gnu-efi package in Ubuntu:
  New

Bug description:
  $ uname -a
  Linux x6 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

  $ lsb_release -rd
  Description:    Ubuntu 16.04.2 LTS
  Release:        16.04

  $ apt-cache policy gnu-efi
  gnu-efi:
    Installed: 3.0.2-1ubuntu1
    Candidate: 3.0.2-1ubuntu1
    Version table:
   *** 3.0.2-1ubuntu1 500
          500 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
          100 /var/lib/dpkg/status

  $ make
  ld -nostdlib -znocombreloc -T /usr/lib/elf_x86_64_efi.lds -shared -Bsymbolic -L /usr/lib -L /usr/lib /usr/lib/crt0-efi-x86_64.o  main.o -o hello.so -lefi -lgnuefi
  ld: /usr/lib/crt0-efi-x86_64.o: relocation R_X86_64_PC32 against undefined symbol `efi_main' can not be used when making a shared object; recompile with -fPIC

  I expected the link to succeed, but it fails with the above error.

  Sure enough, the object code has PC32 relocation records:

  $ readelf -r /usr/lib/crt0-efi-x86_64.o
  Relocation section '.rela.text' at offset 0x238 contains 4 entries:
    Offset          Info           Type           Sym. Value    Sym. Name + Addend
  000000000009  000900000002 R_X86_64_PC32     0000000000000000 ImageBase - 4
  000000000010  000a00000002 R_X86_64_PC32     0000000000000000 _DYNAMIC - 4
  000000000019  000b00000002 R_X86_64_PC32     0000000000000000 _relocate - 4
  000000000020  000c00000002 R_X86_64_PC32     0000000000000000 efi_main - 4

  Relocation section '.rela.reloc' at offset 0x298 contains 1 entries:
    Offset          Info           Type           Sym. Value    Sym. Name + Addend
  000000000000  000200000002 R_X86_64_PC32     0000000000000000 .data + 0

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gnu-efi/+bug/1664725/+subscriptions



More information about the foundations-bugs mailing list