bugGNU GRUB - Bugs: bug #53113, Correctly handle...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #53113: Correctly handle "memset@PLT" references in grub module object files

Submitter:  Brooks Moses <brooksmoses>
Submitted:  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
Open/Closed:  Open Release:  2.02
Release:  Reproducibility:  None
Planned Release:  None

Sat 10 Feb 2018 02:46:14 AM UTC, comment #1: 

Recording an offline conversation with Vladimir(phcoder):

We can safely ignore the GLOBAL_OFFSET_TABLE symbol in the genmoddep.awk script (without concern that it will cause breakage when the module is actually loaded), because that symbol will get removed from the module file when the module file is stripped.

However, we should also add a check (probably to grub-module-checker) to confirm that this removal actually happened.

Brooks Moses <brooksmoses>
Sat 10 Feb 2018 01:26:24 AM UTC, original submission:  

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

Brooks Moses <brooksmoses>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by brooksmoses (Submitted the item)
  • -email is unavailable- added by brooksmoses
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-02-10 brooksmoses Attached File- Added 94_clang_link_support.patch, #43227
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code