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

Submitted by:  Brooks Moses <brooksmoses>
Submitted on:  Sat 10 Feb 2018 01:26:24 AM UTC  
Category: CompilationSeverity: Major
Priority: 5 - NormalItem Group: None
Status: NonePrivacy: Public
Assigned to: NoneOriginator Name: Brooks Moses
Open/Closed: OpenRelease: 
Release: 2.02Reproducibility: 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>


Attached Files


Depends on the following items: None found

Items that depend on this one: None found


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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 10 Feb 2018 01:26:24 AM UTCbrooksmosesAttached File-=>Added 94_clang_link_support.patch, #43227
      Carbon-Copy-=>Added -unavailable-

    Back to the top

    Powered by Savane 3.1-cleanup1