Commit Graph

360 Commits

Author SHA1 Message Date
Peter Jones
5df47d3527 Add missing EFI_VARIABLE_... definition.
This adds the definition for EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS.

Signed-off-by: Peter Jones <pjones@redhat.com>
2024-03-22 10:24:16 -04:00
Peter Jones
27477ba983 Add some missing definitions for system table revisions
Signed-off-by: Peter Jones <pjones@redhat.com>
2024-03-22 10:24:12 -04:00
Peter Jones
699e452654 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>
2024-03-22 10:24:09 -04:00
Peter Jones
06574e4ecd Add EFI_MEMORY_ATTRIBUTE_PROTOCOL
Signed-off-by: Peter Jones <pjones@redhat.com>
2024-03-22 10:24:05 -04:00
Peter Jones
907bf6ce94 Fix some EFI_MEMORY_FOO definitions
Signed-off-by: Peter Jones <pjones@redhat.com>
2024-03-22 10:23:56 -04:00
Nigel Croxon
3b137d634d remove superfluous -fno-stack-check
Signed-off-by: David Müller <d.mueller@elsoft.ch>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2024-03-22 10:23:50 -04:00
Callum Farmer
7f8e2d44ed 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>
2024-03-22 10:23:44 -04:00
Nigel Croxon
eab878741a 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>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2024-03-22 10:23:15 -04:00
Callum Farmer
fb3b3f4c66 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>
2024-03-22 10:08:37 -04:00
Callum Farmer
4cdcf2a37b 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>
2024-03-22 10:08:24 -04:00
Callum Farmer
eadee98bf0 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>
2024-03-22 10:07:56 -04:00
Callum Farmer
0bb329b0bf Merge .plt into .text
ld writes .plt immediately after .text
which corrupts the alignment of .reloc

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:07:53 -04:00
Callum Farmer
262c1f4604 Split out rodata
rodata should be split for security

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:07:49 -04:00
Callum Farmer
136697dd49 .dynsym not required
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:07:44 -04:00
Callum Farmer
0209271936 Clean up size symbols
Tells ld to define them after their markers

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:06:43 -04:00
Callum Farmer
9e47db1193 Add C++ extern C header markers
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:06:43 -04:00
Callum Farmer
bbb501833d X86_64: fix clang
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:06:43 -04:00
Callum Farmer
db870d96d6 Mark _start as function
Currently marked as NOTYPE

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:06:43 -04:00
Callum Farmer
18d53408ff ARM32: _start must be global
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:06:43 -04:00
Callum Farmer
2dcebec0ce 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>
2024-03-22 10:06:43 -04:00
Callum Farmer
bfa3cead95 ARM32: fix L_DYNAMIC
L_DYNAMIC must be 32bits to be PCREL

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:06:43 -04:00
Callum Farmer
f26e5a6eea ctors.S: Fix section definitions
Using @ doesn't work on ARM32

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:06:43 -04:00
Callum Farmer
dd82a45499 riscv: Use new ctors _entry func as entry point
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:06:43 -04:00
Callum Farmer
6c142a6df4 riscv64 lds: fix ctors/dtors
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:06:43 -04:00
Callum Farmer
a68997b11e riscv: Avoid TEXTREL
Use expression instead of variable for _data_size

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2024-03-22 10:06:38 -04:00
Callum Farmer
6f0648992a 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>
2024-03-22 10:05:31 -04: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
Callum Farmer
74b7b5e92c entry.c: Fix null pointer exception
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-07 16:43:09 +01:00
Callum Farmer
9c5403e1e6 Copy marker names from binutils for init/fini
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-04 14:29:47 +01:00
Callum Farmer
b3cc412aad entry.c: .ctors is run backwards
Store forwards, run backwards (65535 to 0)
Ref: 5a8e7e1332/ld/scripttempl/elf.sc (L310)
Ref: https://sourceware.org/binutils/docs/ld/Input-Section-Wildcards.html

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-04 14:29:47 +01:00
Callum Farmer
e2aa099738 lds: Support ctors/dtors with a priority
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-04 14:29:36 +01:00
Callum Farmer
4c938fac30 Merge ctors/dtors rela sections
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-04 13:59:02 +01:00
Callum Farmer
486b1c20c1 Enforce nocombreloc
It is needed to avoid ELF reloc (rela) issues and
to find un-merged reloc sections

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-04 13:59:02 +01:00
Callum Farmer
97499a0cf2 ctors.S: Use LSB defined section perms
Seems to not be correct at the moment, causes errors.

error: expected the entry size
.section .fini_array, "aM", @fini_array

Change per
https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/specialsections.html

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-04 13:59:02 +01:00
Callum Farmer
9b1e06cd0c Use -std instead of --std
--std isn't standardised. lol.

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-05-04 13:59:02 +01:00
Nigel Croxon
24c80efc1a Bump revision to VERSION = 3.0.17 2023-05-02 07:51:45 -04:00
Callum Farmer
bf6fd0405d ia32: No sdata section
There is no small data section on ia32,
this ends up being created as ld puts .got/.got.plt
here due to first declaration

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-04-21 13:38:17 +01:00
Callum Farmer
fd3d975161 ia32 GNUC: Use __asm__ instead of asm
Causes an error when using strict ISO modes as
then asm isn't defined

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-04-21 13:30:00 +01:00
Nigel Croxon
ebd55c4a66 Bump revision to VERSION = 3.0.16 2023-04-17 07:43:00 -04:00
b'Nigel Croxon
bc46fbdc84 Merge /u/gmbr3/gnu-efi/ branch TRUEFALSE into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/49/
2023-04-17 11:39:01 +00:00