2023-03-08 18:32:49 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-2-Clause */
|
2021-03-19 19:38:42 +03:00
|
|
|
/*
|
2024-05-07 15:03:48 +03:00
|
|
|
* Copyright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
|
|
|
|
* Copyright (C) 2018 Alexander Graf <agraf@suse.de>
|
2021-03-19 19:38:42 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice and this list of conditions, without modification.
|
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License as published by the Free Software Foundation;
|
|
|
|
* either version 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
2023-06-16 15:49:47 +03:00
|
|
|
.text
|
2021-03-19 19:38:42 +03:00
|
|
|
.globl _start
|
2023-06-07 17:50:04 +03:00
|
|
|
.type _start,%function
|
2021-03-19 19:38:42 +03:00
|
|
|
_start:
|
|
|
|
addi sp, sp, -24
|
|
|
|
sd a0, 0(sp)
|
|
|
|
sd a1, 8(sp)
|
|
|
|
sd ra, 16(sp)
|
|
|
|
lla a0, ImageBase
|
|
|
|
lla a1, _DYNAMIC
|
|
|
|
call _relocate
|
|
|
|
bne a0, zero, 0f
|
|
|
|
ld a1, 8(sp)
|
|
|
|
ld a0, 0(sp)
|
2023-05-20 21:39:10 +03:00
|
|
|
call _entry
|
2021-03-19 19:38:42 +03:00
|
|
|
ld ra, 16(sp)
|
|
|
|
0: addi sp, sp, 24
|
|
|
|
ret
|
2022-08-06 13:16:29 +03:00
|
|
|
|
2023-06-16 15:49:47 +03:00
|
|
|
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
|
|
|
|
|
|
|
|
.data
|
|
|
|
dummy: .4byte 0
|
|
|
|
|
|
|
|
#define IMAGE_REL_ABSOLUTE 0
|
|
|
|
.section .reloc, "a"
|
|
|
|
label1:
|
|
|
|
.4byte dummy-label1 // Page RVA
|
|
|
|
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
|
|
|
|
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
|
|
|
|
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
|
|
|
|
|
2022-08-06 13:16:29 +03:00
|
|
|
#if defined(__ELF__) && defined(__linux__)
|
|
|
|
.section .note.GNU-stack,"",%progbits
|
|
|
|
#endif
|