URL:
  <http://savannah.gnu.org/bugs/?53113>

                 Summary: Correctly handle "memset@PLT" references in grub
module object files
                 Project: GNU GRUB
            Submitted by: brooksmoses
            Submitted on: Sat 10 Feb 2018 01:26:24 AM UTC
                Category: Compilation
                Severity: Major
                Priority: 5 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: Brooks Moses
        Originator Email: bmo...@google.com
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 
                 Release: 2.02
         Reproducibility: None
         Planned Release: None

    _______________________________________________________

Details:

A recent change to LLVM [1] by Rafael Avila de Espindola causes it to emit
references to intrinsics such as memset as "memset@PLT" rather than simply
"memset".  Per discussion on this change [2], this is expected to be a
non-change once the code is linked; the linker should just degrade this to a
normal "memset" reference when "memset" is a locally-available symbol.  (And,
in practice, that indeed appears to be what standard Linux linkers do with
it.)

However, this LLVM change causes Grub to complain about unsupported relocation
types, because it doesn't implement this ruie.

Also, this change of "memset" to "memset@PLT" causes gas (but not the LLVM
assembler) to emit an undefined _GLOBAL_OFFSET_TABLE_ reference in the object
files, which Grub will need to ignore.  As Rafael notes, this is common
situation; Linux already has similar code [3].

Rafael sent along a (very simple) Grub patch to implement this linking rule
[4, copy attached], which we've tested on several x86 architectures and
confirmed appears to produce correct behavior.

However, I was talking about this with my coworker (and Grub developer)
Vladimir Serbinenko, and he's concerned that the "memset@PLT" reference will
instead require a full GOT implementation in Grub.  I don't think that a full
GOT implementation is the right thing to do here (and it's not the intent of
the LLVM change to require such), but that's a question that needs to be
resolved.

Anyway, regardless of when this (or another) patch lands, I'd like to confirm
that the Grub developers are happy with this general approach, so that we can
go ahead and accept this change into LLVM.

Thanks much!


[1] https://reviews.llvm.org/D42224

[2]
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20180205/522560.html
and subsequent messages

[3]
https://elixir.free-electrons.com/linux/v3.6/source/scripts/mod/modpost.c#L568

[4]
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20180205/522570.html




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Sat 10 Feb 2018 01:26:24 AM UTC  Name: 94_clang_link_support.patch 
Size: 2KiB   By: brooksmoses

<http://savannah.gnu.org/bugs/download.php?file_id=43227>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?53113>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/


_______________________________________________
Bug-grub mailing list
Bug-grub@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-grub

Reply via email to