bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/23930] New: Problems linking objectfiles optimized for size (-Os


From: asavkov at redhat dot com
Subject: [Bug ld/23930] New: Problems linking objectfiles optimized for size (-Os)
Date: Wed, 28 Nov 2018 10:36:25 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=23930

            Bug ID: 23930
           Summary: Problems linking objectfiles optimized for size (-Os)
           Product: binutils
           Version: 2.29
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: asavkov at redhat dot com
  Target Milestone: ---

Created attachment 11416
  --> https://sourceware.org/bugzilla/attachment.cgi?id=11416&action=edit
Reproducer

The issue was found while building linux kernel with
CONFIG_CC_OPTIMIZE_FOR_SIZE (adds -Os to cflags) and
KCFLAGS="-ffunction-sections", while linking vmlinux I get the fillowing
warnings and error:

  ld: warning: dot moved backwards before `.text.__startup_secondary_64'
  ld: warning: dot moved backwards before `.text.__startup_secondary_64'
  ld: final link failed: File truncated
  make: *** [Makefile:1032: vmlinux] Error 1                                    

.iplt section seem to cause issues during linking. This is only reproducible
when vmas and lmas are different, failing section sh_addralign is 1(caused by
-Os) and .iplt is before failing section and the section offset needs to be
just right. I am attaching a small reproducer that I managed to put together
based on linux kernel linker script [1].

This is what I see happening:
.iplt does not have ignored flag set on first pass of
one_lang_size_sections_pass() but has it set on subsequent passes, this results
in dot of the following section moving backwards, resulting in a warning and
section lma not being set properly which later results in s_start being set to
a negative value in assign_file_positions_for_load_sections() yielding a "File
truncated" error.

I have bisected this issue to the following commit: 38b123494b "x86-64: Improve
PLT generation and synthetic PLT symbols"

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/vmlinux.lds.S

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]