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

            Bug ID: 32789
           Summary: sframe: relocatable link of multiple text sections
                    claims FDE to be sorted
           Product: binutils
           Version: 2.45 (HEAD)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: jremus at linux dot ibm.com
  Target Milestone: ---

When performing a relocatable link of multiple text sections of different name
(e.g. .text and .text.hot or when compiling with -ffunction-sections) the
resulting .sframe section claims its SFrame FDE to be sorted on PC.  In general
I think this is wrong, as the ELF object file does not specify load addresses
or order of the individual .text.* sections.  Note that it may be fine for the
Linux Kernel module loader use, if it loads the .text.* sections in the same
order they appear in the .ko.


Sample to demonstrate the issue:

#!/bin/bash
set -e -u -x

cat <<EOF > sframe-foobar.c
void foo(void) {}

void bar(void) { foo(); }
EOF

gcc -fPIC -ffunction-sections -Wa,--gsframe -o sframe-foobar.o -c
sframe-foobar.c
ld -relocatable -o sframe-foobar-relocatable.o sframe-foobar.o
objdump -d --sframe sframe-foobar-relocatable.o
readelf -WSr --sframe sframe-foobar-relocatable.o


The resulting relocatable object looks as follows on s390x (minimized excerpt
of "readelf -WSr --sframe" output):

Section Headers:
  [Nr] Name           Address          Off    Size
  [ 2] .text.foo      0000000000000000 000040 000010
  [ 3] .text.bar      0000000000000000 000050 000020
  [ 4] .rela.text.bar 0000000000000000 0002c8 000018
  [ 7] .sframe        0000000000000000 0000d8 000070
  [ 8] .rela.sframe   0000000000000000 000310 000030

Relocation section '.rela.sframe' at offset 0x310 contains 2 entries:
Offset            Type        Symbol's Name + Addend
000000000000001c  R_390_PC32  .text.foo + 1c
0000000000000030  R_390_PC32  .text.bar + 30

Contents of the SFrame section .sframe:
  Header :

    Version: SFRAME_VERSION_2
    Flags: SFRAME_F_FDE_SORTED
    Num FDEs: 2
    Num FREs: 9

  Function Index :

    func idx [0]: pc = 0x0, size = 16 bytes
    STARTPC         CFA       FP        RA
    0000000000000000  sp+160    u         u
    0000000000000004  sp+160    r16       u*
    0000000000000008  fp+160    r16       u*
    000000000000000e  sp+160    u         u

    func idx [1]: pc = 0x0, size = 32 bytes
    STARTPC         CFA       FP        RA
    0000000000000000  sp+160    u         u
    0000000000000006  sp+160    c-72      c-48
    000000000000000c  sp+320    c-72      c-48
    0000000000000010  fp+320    c-72      c-48
    000000000000001e  sp+160    u         u


While the relocations in .rela.sframe would correctly update the FDE function
start address fields, loading .text.bar at a lower address than .text.foo would
invalidate the SFRAME_F_FDE_SORTED property.

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

Reply via email to