Skip to content

Commit

Permalink
[AIE2] Add missing relocations.
Browse files Browse the repository at this point in the history
  • Loading branch information
mchokshi091101 committed May 30, 2024
1 parent dd36baf commit 33b3aa0
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 15 deletions.
31 changes: 16 additions & 15 deletions lld/ELF/Arch/AIE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,21 +338,22 @@ void AIE::relocateAIE2(uint8_t *Loc, const Relocation &rel,
// automatically generated from the processor description.
#include "AIE2_rela.inc"

// 72 : (symbol_addr_AR + addend ) : addr [19..0]@0 in w08[4] //
// with default addend 0 73 : (symbol_addr_AR + addend ) : addr
// [19..0]@0 in w32[1] // with default addend 0
case 72:
case 73:
checkUInt(Loc, Val, 20, rel);
patch4bytes(Loc, Val, 19, 0, 12);
return;
//74 : (symbol_addr_AR + addend ) : t01u [0..0]@0 in w08[4] // with default addend 0
//75 : (symbol_addr_AR + addend ) : t01u [0..0]@0 in w32[1] // with default addend 0
case 74:
case 75:
checkUInt(Loc, Val, 1, rel);
patch4bytes(Loc, Val, 0, 0, 31);
return;
// 50 : (symbol_addr_AR + addend ) : addr [19..0]@0 in w08[4] //
// with default addend 0 52 : (symbol_addr_AR + addend ) : addr [19..0]@0
// in w32[1] // with default addend 0
case 50:
case 52:
checkUInt(Loc, Val, 20, rel);
patch4bytes(Loc, Val, 19, 0, 12);
return;
// 51 : (symbol_addr_AR + addend ) : w32 [31..0]@0 in w08[4] // with
// default addend 0 53 : (symbol_addr_AR + addend ) : w32 [31..0]@0 in
// w32[1] // with default addend 0
case 51:
case 53:
checkUInt(Loc, Val, 32, rel);
patch4bytes(Loc, Val, 31, 0, 0);
return;

default:
error(getErrorLocation(Loc) +
Expand Down
51 changes: 51 additions & 0 deletions lld/test/ELF/AIE/aie2/aie2-jal32.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# (c) Copyright 2024 Advanced Micro Devices, Inc. or its affiliates
# REQUIRES: aie
# RUN: yaml2obj %s -o %t.o
# RUN: ld.lld -Ttext=69630 %t.o -o %t
# RUN: obj2yaml %t | FileCheck %s
# RUN: llvm-objdump -d %t | FileCheck -check-prefix=CHECK_ASM %s
#
# CHECK: - Name: .text
# CHECK: Content: 950000184B0301000100010001000100
#
# CHECK_ASM: 69630: 95 00 00 18 4b 03 j #0x69630

--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_AIE
Flags: [ EF_AIE_AIE2 ]
SectionHeaderStringTable: .strtab
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x10
Content: '95000000000001000100010001000100'
- Name: .rela.text
Type: SHT_RELA
Flags: [ SHF_INFO_LINK ]
Link: .symtab
AddressAlign: 0x4
Info: .text
Relocations:
- Symbol: foo
Type: R_AIE_1
- Type: SectionHeaderTable
Sections:
- Name: .strtab
- Name: .text
- Name: .rela.text
- Name: .symtab
Symbols:
- Name: foo
Section: .text
Binding: STB_GLOBAL
...
58 changes: 58 additions & 0 deletions lld/test/ELF/AIE/aie2/aie2-rela1.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# (c) Copyright 2024 Advanced Micro Devices, Inc. or its affiliates
# REQUIRES: aie
# RUN: yaml2obj %s -o %t.o
# RUN: ld.lld -Ttext=0 %t.o -o %t
# RUN: obj2yaml %t | FileCheck %s
#
# CHECK: - Name: .text
# CHECK: Content: 000080FFFF0700000000000000000000

--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_AIE
Flags: [ EF_AIE_AIE2 ]
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x0000000000000004
Content: 00000000000000000000000000000000
- Name: .rela.text
Type: SHT_RELA
Link: .symtab
AddressAlign: 0x0000000000000004
EntSize: 0x000000000000000C
Info: .text
Relocations:
- Offset: 0x0000000000000000
Symbol: foo
Type: R_AIE_1
- Name: .note.GNU-stack
Type: SHT_PROGBITS
AddressAlign: 0x0000000000000001
Content: ''
- Name: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Flags: [ SHF_EXCLUDE ]
Link: .symtab
AddressAlign: 0x0000000000000001
Content: ''
Symbols:
- Name: _main
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
Size: 0x0000000000000010
- Name: foo
Section: .text
Value: 0xFFFFF
Binding: STB_GLOBAL
...
76 changes: 76 additions & 0 deletions lld/test/ELF/AIE/aie2/aie2-rela50.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# (c) Copyright 2024 Advanced Micro Devices, Inc. or its affiliates
# REQUIRES: aie
# RUN: yaml2obj %s -o %t.o
# RUN: ld.lld -Tdata=0 %t.o -o %t
# RUN: obj2yaml %t | FileCheck %s
#
# CHECK: - Name: .data
# CHECK: Content: 0100000000000000DEBC0A0008000000
# CHECK: - Name: globalData
# CHECK-NEXT: Type: STT_OBJECT
# CHECK-NEXT: Section: .data
# CHECK-NEXT: Binding: STB_GLOBAL
# CHECK-NEXT: Value: 0x8

--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_AIE
Flags: [ EF_AIE_AIE2 ]
SectionHeaderStringTable: .strtab
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x10
- Name: .data.align.8
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
AddressAlign: 0x8
Content: '0100000000000000'
- Name: .data.align.4
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
AddressAlign: 0x4
Content: DEBC0A0000000000
- Name: .rela.data.align.4
Type: SHT_RELA
Flags: [ SHF_INFO_LINK ]
Link: .symtab
AddressAlign: 0x4
Info: .data.align.4
Relocations:
- Offset: 0x4
Symbol: globalData
Type: R_AIE_50
- Name: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Flags: [ SHF_EXCLUDE ]
Link: .symtab
AddressAlign: 0x1
Symbols: [ globalData ]
Symbols:
- Name: bigData
Type: STT_OBJECT
Section: .data.align.8
Binding: STB_GLOBAL
Size: 0x8
- Name: globalData
Type: STT_OBJECT
Section: .data.align.4
Binding: STB_GLOBAL
Size: 0x4
- Name: globalPtr
Type: STT_OBJECT
Section: .data.align.4
Binding: STB_GLOBAL
Value: 0x4
Size: 0x4
...

0 comments on commit 33b3aa0

Please sign in to comment.