Commit graph

373 commits

Author SHA1 Message Date
Callum Farmer
adbd7ae7b6 Remove 64k gap on ARM32
While binutils 2.25 incorrectly changed the page size
to 64K, the second part of that fix prevents the bug
anyways

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-12-04 10:43:59 +00:00
Callum Farmer
c600b4e9a5 arm64 lds: move 64K gap to reloc
The PE32 header means code ends at end of text, unlike
ELF where its mostly dynamic

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-11-28 16:34:07 +00:00
Callum Farmer
a5f306c401 ctors.S: Align with linker scripts
Remove end padding
Change start padding to 16

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-11-28 16:34:07 +00:00
Callum Farmer
ebe2358ae7 Add EFI_NORETURN for declspec
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-08-12 12:58:02 +01:00
Callum Farmer
3d83038cbc Rename ALIGN to EFI_ALIGN
Avoid conflict with other libraries

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-08-12 12:43:40 +01:00
Callum Farmer
965f557ab7 Update OS Indications to 2.10
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-07-10 15:54:15 +01:00
Callum Farmer
fd37dafe0b Update memory types to 2.10
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-07-10 15:31:54 +01:00
Callum Farmer
de6f9259e8 Update error/warning codes to 2.10
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-07-09 17:25:32 +01:00
Callum Farmer
7c6975aa56 Update table revisions to 2.10
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-07-09 17:25:31 +01:00
b'Nigel Croxon
f5bb5112de Merge /u/gmbr3/gnu-efi/ branch shim into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/61/
2023-07-07 13:13:41 +00:00
Callum Farmer
cd78649395 ARM32: Only use 4K pages
Turns out some linkers have set page size to 64K on ARM32 aswell
so apply the same fix as ARM64

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-07-06 19:16:32 +01:00
Peter Jones
6ba063ff00 Add missing EFI_VARIABLE_... definition.
This adds the definition for EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS.

Signed-off-by: Peter Jones <pjones@redhat.com>
2023-07-06 14:26:06 +01:00
Peter Jones
93b2524a96 Add some missing definitions for system table revisions
Signed-off-by: Peter Jones <pjones@redhat.com>
2023-07-06 14:25:28 +01:00
Peter Jones
deb8a7f267 Make CopyMem() and SetMem() be EFIAPI
For wildly unknown reasons, EFI Boot Services includes CopyMem() and
SetMem() functions, and they are marked as EFIAPI functions.

This patch marks gnu-efi's CopyMem() and SetMem() as EFIAPI functions,
and makes their exposed API match the misguided nonsense in the EFI
spec, so that they can be used there in a test environment.

Signed-off-by: Peter Jones <pjones@redhat.com>
2023-07-06 14:23:42 +01:00
Peter Jones
ce625f353e Add EFI_MEMORY_ATTRIBUTE_PROTOCOL
Signed-off-by: Peter Jones <pjones@redhat.com>
2023-07-06 14:21:27 +01:00
Peter Jones
108666ffe9 Fix some EFI_MEMORY_FOO definitions
Signed-off-by: Peter Jones <pjones@redhat.com>
2023-07-06 14:20:27 +01:00
Nigel Croxon
4b6f37e74c remove superfluous -fno-stack-check
Signed-off-by: David Müller <d.mueller@elsoft.ch>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2023-07-03 09:19:50 -04:00
Callum Farmer
bbffe42b46 Move OPTNONE macro to eficompiler.h
This is also useful in downstream projects so add it
to public header

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-06-21 22:19:54 +01:00
Callum Farmer
6f333cfc91 Tail calls break ctors/dtors
Add macro EFI_NO_TAIL_CALL which disables tail call
optimization on a per-function basis

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-06-21 20:33:35 +01:00
Callum Farmer
708f66acfe riscv64: ignore unknown relocs
Sometimes ld emits relocs such as R_RISCV_64 for unwind symbols
these don't need to be handled yet so just can be skipped otherwise
the binary will never load

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-06-21 12:28:58 +01:00
Callum Farmer
58dce6991b riscv64: fix image
- Make it actually work
- Split text/data/reloc/rodata sections
- Move hash sections to past end of image
  (un-needed in PE)
- Correct section & file alignment
- Correct image size

Builds correctly but untested

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-06-21 12:28:58 +01:00
Callum Farmer
50b27a854c ARM32: fix image
- Make it actually work
- Split text/data/reloc/rodata sections
- Move hash sections to past end of image
  (un-needed in PE)
- Correct section & file alignment
- Correct image size
- rename .reloc to .areloc within ELF
  as only on ARM32 does this name cause
  it to be marked as REL and subsequently
  mistakenly added to RELSZ

Builds correctly & tested working in QEMU

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-06-21 12:28:58 +01:00
Callum Farmer
8abf159da6 Merge .plt into .text
ld writes .plt immediately after .text
which corrupts the alignment of .reloc

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-06-21 12:28:58 +01:00
Callum Farmer
b3e80c38bc Split out rodata
rodata should be split for security

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-06-21 12:28:58 +01:00
Callum Farmer
1be024100e .dynsym not required
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-06-21 12:28:58 +01:00
Callum Farmer
2011093544 Clean up size symbols
Tells ld to define them after their markers

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-06-21 12:28:58 +01:00
Callum Farmer
5e85f477fb Add C++ extern C header markers
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-06-21 12:28:45 +01:00
Callum Farmer
53b89f528d X86_64: fix clang
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-06-10 19:25:18 +01:00
Callum Farmer
64027ee986 Mark _start as function
Currently marked as NOTYPE

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-06-07 15:54:41 +01:00
Callum Farmer
db351e8a78 ARM32: _start must be global
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-06-02 22:14:11 +01:00
Callum Farmer
039ca9d93c Add full Data Directories table
Microsoft dumpbin doesn't like the binary if
the full table doesn't exist

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-31 19:16:53 +01:00
b'Nigel Croxon
67762bdb85 Merge /u/gmbr3/gnu-efi/ branch ia32 into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/54/
2023-05-23 14:52:46 +00:00
Callum Farmer
0fe8def9b6 ARM32: fix L_DYNAMIC
L_DYNAMIC must be 32bits to be PCREL

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-23 15:44:14 +01:00
Callum Farmer
584425eb2a ctors.S: Fix section definitions
Using @ doesn't work on ARM32

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-23 15:37:42 +01:00
b'Nigel Croxon
a1ffc0d4ee Merge /u/gmbr3/gnu-efi/ branch ia32 into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/53/
2023-05-22 11:50:55 +00:00
Callum Farmer
d96b34e0dd riscv: Use new ctors _entry func as entry point
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-20 20:02:49 +01:00
Callum Farmer
d8e6b531ef riscv64 lds: fix ctors/dtors
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-20 19:13:14 +01:00
Callum Farmer
1e0f0df537 riscv: Avoid TEXTREL
Use expression instead of variable for _data_size

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-20 15:34:03 +01:00
Callum Farmer
9e6cb2150b Avoid processor dependent sizes in assembly
.word -> .2byte
.short -> .2byte
.long -> .4byte
.quad -> .8byte

Reference: b83f0845b5
Fixes: https://sourceforge.net/p/gnu-efi/bugs/37/

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-20 14:50:46 +01:00
b'Nigel Croxon
20d8d8adc7 Merge /u/moodyhunter/gnu-efi/ branch master into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/52/
2023-05-18 14:14:54 +00:00
b'Nigel Croxon
9835e11ebe Merge /u/gmbr3/gnu-efi/ branch ia32 into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/51/
2023-05-16 13:06:32 +00:00
Nigel Croxon
bbc2b528e0 Revert "Make ELF constructors/destructors work"
This reverts commit fe76d597a9.
2023-05-16 09:05:00 -04:00
Nigel Croxon
fe76d597a9 Make ELF constructors/destructors work
Since commit [4f8b339fac]
Simple EFI tools like for example t.c from the apps directory crash.

The reason seems to be a wrong null-pointer check in the
ctors()/dtors() functions in lib/entry.c.
sourceforge.net/u/davemueller

Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2023-05-16 08:34:07 -04:00
Moody Liu
1de5094978 riscv64: adjust type definitions
CHAR8 needs to be defined while BOOLEAN should be removed
here to prevent typedef conflicts

Signed-off-by: Moody Liu <mooodyhunter@outlook.com>
2023-05-13 17:57:24 +01:00
Callum Farmer
99730f29b2 Structs with no linkage
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-11 15:12:36 +01:00
Callum Farmer
ba150f34d6 Add test for ctors & dtors with a priority
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-07 16:43:20 +01:00
Callum Farmer
e1efa4d70a No clean
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-07 16:43:20 +01:00
Callum Farmer
7dac18443f Re-write entry.c/ctors.S to work better
* Make entry.c work correctly in reverse order
* Remove incorrectly sized (on non-32bit) NULLs from ctors.S

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-07 16:43:20 +01:00
Callum Farmer
4c6962457f entry.c: fini_array is run backwards
fini_array is 65535 to 0 but stored 0 to 65535

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-07 16:43:20 +01:00
Callum Farmer
9dbfe1c365 Align all ctors/dtors start to 16
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-07 16:43:19 +01:00