[EXTERNAL] Re: [PATCH v2 0/3] aarch64: Relocation fixes and LTO

Evgeny Karpov Evgeny.Karpov@microsoft.com
Fri Dec 6 11:22:19 GMT 2024


Tuesday, November 19, 2024
Martin Storsjö <martin@martin.st> wrote:

> No further objections from me, to this patchset.
>
> I can't really say I know exactly what patch 1 does, though - it would be 
> nice to have a concrete user level example of what kind of input was 
> handled incorrectly before and which now should work though (and which 
> related cases were handled correctly by the code before which now still 
> should keep working as it did before).

Thank you for the review.
Here is an update on the current patch series ( https://sourceware.org/pipermail/binutils/2024-November/137713.html ), which has actually shrunk to one patch.

"[PATCH v2 2/3] aarch64: Add AArch64 support to libiberty" is no longer needed 
as it was merged by syncing with the GCC repository.
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=461248c1433714584060fd3a41efe28088aa855b

"[PATCH v2 3/3] Support relocation for weak references" is no longer needed after
refactoring the GCC implementation and merging changes.
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5181d982c34a38a552f6d4d19adb039171893ad7

Could "[PATCH v2 1/3] aarch64: Fix symbol reduction for relocations" be merged 
if there are no more objections?

Clarification on other changes in
"[PATCH v2 1/3] aarch64: Fix symbol reduction for relocations"

The example below shows how changes affect the relocation tables.

static int test_static(int* val)
{
    return *val + 1;
}

int (*get_test_static(void))(int* val) 
{
    return test_static;
}

static int first __attribute__((section("section")));
static int second __attribute__((section("section"))) = 10;

int main() {
    if (get_test_static()(&second) != 11)
        return 1;

	return 0;
}

1. Without applying the patch and introducing tc_fix_adjustable.
test_static and second symbols are reduced to section names which leads
to an increased offset value and the removal of information about the symbol
that requires relocation.

 Offset    Type              Applied To         Index     Name
 --------  ----------------  -----------------  --------  ------
 0000001C  PAGEBASE_REL21             90000000         8  .text
 00000020  PAGEOFFSET_12A             91000000         8  .text
 00000038  BRANCH26                   94000000        12  __main
 0000003C  BRANCH26                   94000000         4  get_test_static
 00000044  PAGEBASE_REL21             90000020        10  section
 00000048  PAGEOFFSET_12A             91001000        10  section

2. Introducing tc_fix_adjustable and applying
+ if (S_GET_STORAGE_CLASS (sym) == C_STAT)
+    return false;

 RELOCATIONS #1
                                                Symbol    Symbol
 Offset    Type              Applied To         Index     Name
 --------  ----------------  -----------------  --------  ------
 0000001C  PAGEBASE_REL21             90000000         0  test_static
 00000020  PAGEOFFSET_12A             91000000         0  test_static
 00000038  BRANCH26                   94000000        12  __main
 0000003C  BRANCH26                   94000000         4  get_test_static
 00000044  PAGEBASE_REL21             90000020        10  section
 00000048  PAGEOFFSET_12A             91001000        10  section

3. Introducing tc_fix_adjustable and applying

+  if (S_GET_STORAGE_CLASS (sym) == C_STAT)
+    return false;
+
+  if (symbol_get_bfdsym (sym)->section->flags & (SEC_DATA | SEC_READONLY))
+    return false;

RELOCATIONS #1
                                                Symbol    Symbol
 Offset    Type              Applied To         Index     Name
 --------  ----------------  -----------------  --------  ------
 0000001C  PAGEBASE_REL21             90000000         0  test_static
 00000020  PAGEOFFSET_12A             91000000         0  test_static
 00000038  BRANCH26                   94000000        15  __main
 0000003C  BRANCH26                   94000000         5  get_test_static
 00000044  PAGEBASE_REL21             90000000         8  second
 00000048  PAGEOFFSET_12A             91000000         8  second

Regards
Evgeny



More information about the Binutils mailing list