bugGNU GRUB - Bugs: bug #64812, Support for relocation type in...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #64812: Support for relocation type in grub2

Submitter:  Leung Wing Chung <l00862805>
Submitted:  Wed 25 Oct 2023 01:48:46 AM UTC
   
 
Category:  Compilation Severity:  Major
Priority:  5 - Normal Item Group:  Feature Request
Status:  None Privacy:  Public
Assigned to:  None Originator Name:  Ricky Leung
Open/Closed:  Open Release:  2.00
Release:  Reproducibility:  Every Time
Planned Release:  None

Wed 25 Oct 2023 01:48:46 AM UTC, original submission:  

I am a compiler engineer currently working on a project to run Grub2 with Clang + LLVM instead of GCC. I wanted to reach out to the community to discuss an issue and inquire about your plans to support relocation type.

When I am building Grub2 with `time osc build --root=$(pwd)/build `, I received the following error message: "unsupported relocation 0x108".

Upon further investigation, I discovered that this error is due to the different approaches used by GCC and LLVM when handling relocations. Specifically, when compiling the code with GCC using the `-mcmodel=large` flag, the relocation types `R_AARCH64_ADR_PRE`, `R_AARCH64_ADD_ABS`, and `R_AARCH64_ABS64` were used. However, when using LLVM with the same flag, the relocation type `R_AARCH64_MOVW_UABS_G0_NC` was encountered. Here's the example:

test.c:

```c
const char *test(void){
return "xx";
}
```

Execution with GCC:

```cmd
$ gcc -o test.o -c test.c -mcmodel=large
$ readelf -r test.o

Relocation section '.rela.text' at offset 0x200 contains 3 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000000000  000200000113 R_AARCH64_ADR_PRE 0000000000000000 .text + 10
000000000004  000200000115 R_AARCH64_ADD_ABS 0000000000000000 .text + 10
000000000010  000500000101 R_AARCH64_ABS64   0000000000000000 .rodata + 0

Relocation section '.rela.eh_frame' at offset 0x248 contains 1 entry:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
00000000001c  000200000105 R_AARCH64_PREL32  0000000000000000 .text + 0
```

Execution with Clang:

```cmd
$ clang -o test.o -c test.c -mcmodel=large
$ readelf -r test.o

Relocation section '.rela.text' at offset 0x1c0 contains 4 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000000000  000700000108 R_AARCH64_MOVW_UA 0000000000000000 .rodata.str1.1 + 0
000000000004  00070000010a R_AARCH64_MOVW_UA 0000000000000000 .rodata.str1.1 + 0
000000000008  00070000010c R_AARCH64_MOVW_UA 0000000000000000 .rodata.str1.1 + 0
00000000000c  00070000010d R_AARCH64_MOVW_UA 0000000000000000 .rodata.str1.1 + 0

Relocation section '.rela.eh_frame' at offset 0x220 contains 1 entry:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
00000000001c  000600000104 R_AARCH64_PREL64  0000000000000000 .text + 0
```

To address this issue and ensure compatibility across different compilers, I would like to know if there are any plans to support relocation type in Grub2. his would enable seamless compilation and execution of Grub2 using both GCC and LLVM with the `-mcmodel=large` flag.

Thank you for your time and contributions.

Leung Wing Chung <l00862805>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by l00862805 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code