summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* Structs with no linkageCallum Farmer2023-05-112-6/+8
| | | | Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
* Re-write entry.c/ctors.S to work betterCallum Farmer2023-05-072-22/+25
| | | | | | | * 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>
* entry.c: fini_array is run backwardsCallum Farmer2023-05-071-1/+1
| | | | | | fini_array is 65535 to 0 but stored 0 to 65535 Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
* entry.c: Fix null pointer exceptionCallum Farmer2023-05-071-4/+4
| | | | Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
* Copy marker names from binutils for init/finiCallum Farmer2023-05-042-12/+12
| | | | Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
* entry.c: .ctors is run backwardsCallum Farmer2023-05-041-1/+1
| | | | | | | | Store forwards, run backwards (65535 to 0) Ref: https://github.com/bminor/binutils-gdb/blob/5a8e7e1332c35d4d5bed67adccd9d66f5cf62c4e/ld/scripttempl/elf.sc#L310 Ref: https://sourceware.org/binutils/docs/ld/Input-Section-Wildcards.html Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
* ctors.S: Use LSB defined section permsCallum Farmer2023-05-041-4/+4
| | | | | | | | | | | | 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>
* ia32 GNUC: Use __asm__ instead of asmCallum Farmer2023-04-211-1/+1
| | | | | | | Causes an error when using strict ISO modes as then asm isn't defined Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
* make: Fix shell exit status handlingRichard Hughes2023-04-041-1/+1
| | | | | | | | | Right now whenever we have shell commands with loops, errors in the middle are accidentally ignored, and make continues to process commands. This adds 'set -e' to all of those, so they'll propagate back up. Signed-off-by: Peter Jones <pjones@redhat.com>
* Implement Print(L"%p", ptr);Peter Jones2023-04-041-0/+14
| | | | Signed-off-by: Peter Jones <pjones@redhat.com>
* Make ELF constructors and destructors workPeter Jones2023-03-284-44/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes setup and teardown functions defined with __attribute__((__constructor__) and __attribute__((__destructor__)) work in normal circumstances in EFI binaries. A couple of notes: - it implements both the old-style .ctors/.dtors methods and the newer style .init_array/.fini_array ELF constructor and destructor arrays, processed in the order: .init_array[] .ctors[] efi_main() .dtors[] .fini_array[] - Destructors will only be called if efi_main() exits using "return"; any call to Exit() will still longjmp() past them. - InitializeLib() has already been called before constructors run, so they don't need to call it (and neither does anything else.) For compatibility, it has been altered so calling it more than once is safe. - No attempt is made to handle any constructor or destructor with a prototype other than "void func(void);", but note that InitializeLib has been called, so LibImageHandle, ST, BS, and RT are set. - The init_array/ctor/dtor/fini_array lists aren't the using the GNU "CONSTRUCTOR" output section command, so they don't start with a size. - The lists are individually sorted during the link stage via SORT_BY_NAME() in the linker script. - The default (empty) init_array/ctor/dtor/fini_array lists are padded out to 8-byte alignment with ".p2align 3, 0", and each list always has at least one ".long 0" at the end of it (even if it's completely empty). As a result, they can have NULLs that need to be skipped. The sections they're in are mergeable, so the NULLs don't have to be exclusively at the end. - The ia64 and mips64el arches have not been tested. Signed-off-by: Peter Jones <pjones@redhat.com>
* Semi-asciibetize _Print()'s formatters.Peter Jones2023-03-281-67/+65
| | | | | | | This is ascii order but with upper and lower case letters mixed, so things like 'X' and 'x' that use fallthrough still stay together. Signed-off-by: Peter Jones <pjones@redhat.com>
* Remove the accidentally created lib/Makefile.origPeter Jones2023-03-281-91/+0
| | | | | | This was added in dae0b4b0b0d522caecf09123db2cf0250c37a169. Signed-off-by: Peter Jones <pjones@redhat.com>
* riscv: Update SPDX license identifiersbmeng@tinylab.org2023-03-082-2/+2
| | | | | | | | | | | | | | | | | | The whole gnu-efi project is licensed under BSD license, see [1]. However some of the RISC-V codes have conflict license identifiers: - Some mention GPL-2.0+ in the SPDX license part, but the long license header indicates it's actually BSD and GPL-2.0+ dual-licensed - Some mention GPL-2.0+ in the SPDX license part only - Some do not have any license indication To have a matching license with the whole project, this commit updates all RISC-V codes to have the correct SPDX license identifiers (GPL-2.0+ or BSD dual-license). Link: https://sourceforge.net/p/gnu-efi/ [1] Signed-off-by: Bin Meng <bmeng@tinylab.org> Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* Merge /u/mingtaoxt/gnu-efi/ branch master into masterb'Nigel Croxon2022-11-165-1/+159
|\ | | | | | | https://sourceforge.net/p/gnu-efi/code/merge-requests/29/
| * use jr instead of jirlzhoumingtao2022-07-071-2/+2
| | | | | | | | jirl -> jr
| * Add support for LoongArch64 architecturezhoumingtao2021-12-305-1/+159
| |
* | */*.S: add non-executable GNU stack marking on ELF-linuxSergei Trofimovich2022-08-0819-3/+73
| | | | | | | | | | | | | | | | | | | | | | | | binutils-2.39 enabed a few warning by default (https://sourceware.org/pipermail/binutils/2022-August/122246.html): > The ELF linker will now generate a warning message if the stack is made executable. Let's suppress the warnings in assembly files by adding non-executables stack markings. This fixes at least systemd build which uses '-Wl,--fatal-warnings': https://github.com/systemd/systemd/issues/24226
* | lib/Makefile: add .o file dependency on libsubdirs targetsSergei Trofimovich2022-07-251-2/+2
|/ | | | | | | | | Without the change there is no guarantee that .o files will be built after directories are created for them and build fails as: gcc -I/build/gnu-efi-code//lib ... -c lib/runtime/rtstr.c -o runtime/rtstr.o Assembler messages: Fatal error: can't create runtime/rtstr.o: No such file or directory
* Merge /u/abeato/gnu-efi/ branch add-guids into masterb'Nigel Croxon2021-07-161-0/+1
|\ | | | | | | https://sourceforge.net/p/gnu-efi/code/merge-requests/26/
| * Add definitions for the EFI device tree tableAlfonso Sánchez-Beato2021-07-161-0/+1
| | | | | | | | | | | | | | Add definitions for the EFI device tree table, as specified in UEFI specification 2.9 (March 2021). Signed-off-by: Alfonso Sánchez-Beato <alfonso.sanchez-beato@canonical.com>
* | Fix VS2019 Code Analysis warningsPete Batard2021-07-163-3/+3
|/ | | | | | | | | | When compiling for x64, Visual Studio 2019's Code Analysis produces the following warnings: C:\Projects\gnu-efi\lib\print.c(1380): warning C26451: Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2). C:\Projects\gnu-efi\lib\smbios.c(47): warning C26451: Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2). C:\Projects\gnu-efi\lib\str.c(289): warning C26451: Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2). Fix these by adding an explicit cast to UINTN.
* lib/str: simplify Atoi()Heinrich Schuchardt2021-06-221-1/+1
| | | | | | | | | | Checking that str is non-zero is superfluous in (*str && *str == ' ') 0x20 is always non-zero. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* lib/misc: avoid NULL dereference in LibInsertToTailOfBootOrderHeinrich Schuchardt2021-06-221-4/+4
| | | | | | | AllocatePool() may return NULL. We must check the return value before dereferencing it. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* lib/hand: missing va_end() in LibReinstallProtocolInterfaces()Heinrich Schuchardt2021-06-221-1/+3
| | | | | | For each va_start() there must be a call to va_end(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* Merge /u/xypron/gnu-efi/ branch riscv64 into masterb'Nigel Croxon2021-04-055-2/+144
|\ | | | | | | https://sourceforge.net/p/gnu-efi/code/merge-requests/17/
| * Initial support for RISCV64Heinrich Schuchardt2021-04-014-1/+143
| | | | | | | | | | | | Add the RISCV64 architecture Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * Undefined Status in LibGetVariableAndSize()Heinrich Schuchardt2021-03-191-1/+1
| | | | | | | | | | | | | | | | | | GrowBuffer() expects that parameter Status is initialized. LibGetVariableAndSize() currently passes random data from the stack. Initialize variable Status. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | Merge /u/xypron/gnu-efi/ branch va_args into masterb'Nigel Croxon2021-04-051-0/+3
|\ \ | | | | | | | | | https://sourceforge.net/p/gnu-efi/code/merge-requests/16/
| * | lib/hand: missing va_endHeinrich Schuchardt2021-04-041-0/+3
| |/ | | | | | | | | | | | | | | | | For each va_start() there must be a va_end(). Correct LibInstallProtocolInterfaces() and LibUninstallProtocolInterfaces(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | Merge /u/xypron/gnu-efi/ branch xtoi into masterb'Nigel Croxon2021-04-051-1/+1
|\ \ | | | | | | | | | https://sourceforge.net/p/gnu-efi/code/merge-requests/15/
| * | lisb/str.c: simplify xtoi()Heinrich Schuchardt2021-04-041-1/+1
| |/ | | | | | | | | | | If str == ' ', str has to be non-zero. No extra check is needed. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | Merge /u/kagurazakakotor/gnu-efi/ branch shell-protocol into masterb'Nigel Croxon2021-04-052-8/+13
|\ \ | | | | | | | | | https://sourceforge.net/p/gnu-efi/code/merge-requests/13/
| * | Add EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL definitionsJiaqing Zhao2020-11-151-2/+3
| | | | | | | | | | | | Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
| * | Move EFI_SHELL_PARAMETERS_PROTOCOL related definitions to efishell.hJiaqing Zhao2020-11-152-5/+4
| | | | | | | | | | | | | | | | | | | | | As EFI_SHELL_PARAMETERS_PROTOCOL is also defined in UEFI Shell Spec, put it together with EFI_SHELL_PROTOCOL. Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
| * | Add EFI_SHELL_PROTOCOL definitionsJiaqing Zhao2020-11-151-4/+9
| | | | | | | | | | | | Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
* | | Merge /u/kagurazakakotor/gnu-efi/ branch protocol-header into masterb'Nigel Croxon2021-04-051-0/+1
|\ \ \ | |_|/ |/| | | | | https://sourceforge.net/p/gnu-efi/code/merge-requests/12/
| * | Add Device Path Utilities Protocol supportKagurazaka Kotori2020-07-231-0/+1
| | | | | | | | | | | | Signed-off-by: Kagurazaka Kotori <kagurazakakotori@gmail.com>
* | | Define UnicodeSPrint/UnicodeVSPrint as our main SPrint/VSPrint callsPete Batard2021-03-083-11/+11
| | | | | | | | | | | | | | | | | | | | | Per https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/PrintLib.h those are the names used by EDK2, so make these our official names as well. For compatibility with older gnu-efi versions, also keep SPrint and VSPrint defined.
* | | Use EFI_FILE_SYSTEM_VOLUME_LABEL rather than EFI_FILE_SYSTEM_VOLUME_LABEL_INFOPete Batard2021-03-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Per https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Guid/FileSystemVolumeLabelInfo.h the EDK2 uses EFI_FILE_SYSTEM_VOLUME_LABEL and EFI_FILE_SYSTEM_VOLUME_LABEL_ID rather than EFI_FILE_SYSTEM_VOLUME_LABEL_INFO and EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID. We redefine those to the proper EDK2 names, while also adding defines for compatibility.
* | | Fix CopyMem() not handling overlapsPete Batard2021-03-081-9/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | Per https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/BaseMemoryLib.h "(CopyMem) must handle the case where SourceBuffer overlaps DestinationBuffer". Having the gnu-efi version of CopyMem differ from the EDK2 version can lead to extremely hard to troubleshoot issues as well as very unexpected results. So make sure our version follows the same guidelines.
* | | Remove the need for other include paths besides <gnu-efi>/incPete Batard2021-02-181-92/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | Having to add specific arch include paths and then <gnu-efi>/lib to be able to use gnu-efi in an application is annoying. This patch ensures that the library itself takes care of including the relevant headers, and that one needs only to add <gnu-efi>/inc in their include path to be able to use gnu-efi.
* | | Add AsciiPrint and AsciiVSPrintPete Batard2021-02-181-2/+60
| |/ |/| | | | | | | | | | | | | | | | | Per https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/PrintLib.h AsciiPrint() is the official name of APrint() so declare it as such and define an APrint alias for compatibility. Also add an AsciiVSPrint() to print a formatted ASCII string to a buffer using a va_list. AsciiPrint() too is defined in EDK2's PrintLib.h, though our implementation just invokes the Unicode version and then converts the buffer to ASCII.
* | Replace Pause() macro with new library functionKagurazaka Kotori2020-07-222-1/+16
|/ | | | | | | | Key input should be consumed to prevent WaitForKey event from being always triggered and potential buffer overflow. This fixes issue #26. Signed-off-by: Kagurazaka Kotori <kagurazakakotori@gmail.com>
* Add Simple Text Input Ex Protocol supportKagurazaka Kotori2020-07-211-0/+5
| | | | Signed-off-by: Kagurazaka Kotori <kagurazakakotori@gmail.com>
* Add SMBIOS 3.0 table supportPete Batard2020-05-111-0/+1
| | | | Also fix some small whitespace issues.
* * Fixed typeo lib/error.c EFI_WARN_UNKNOWN_GLYPH definition.Nigel Croxon2019-01-093-19/+21
| | | | | | | | | | | | | | | On couple of locations in runtime string library (rtstr.c) there are calls to non-runtime variant of StrLen function. * Another issue is with formatting 1394 paths. The F1394_DEVICE_PATH::Guid is formatted as %g, but 1394 GUID is 8 byte integer, not EFI_GUID and therefore should be formatted as e.g. %016lx (as edk2 does). * Beyond what's mentioned above, changed the format of the harddrive path, so it's in line with edk2 format and spec (2.7 errata A, chapter 10.6.1.6, table 102). Signed-off-by: Nigel Croxon <ncroxon@redhat.com> Signed-off-by: manison <manison@users.sf.net>
* Set '\0' properly in StrnCpy()Gary Lin2018-10-121-1/+1
| | | | | | | | | The arguments to SetMem() were wrong. Besides, SetMem() should start at "Dest + Size" since "Size" will be smaller than "Len" if they are not equal. Signed-off-by: Gary Lin <glin@suse.com> Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* Implement StrnCat() without StrnCpy()Gary Lin2018-10-111-2/+7
| | | | | | | | StrnCpy() doesn't guarantee the dest string will be null-terminated, so we shouldn't use StrnCpy(). Signed-off-by: Gary Lin <glin@suse.com> Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* Set '\0' properly in StpnCpy()Gary Lin2018-10-111-2/+2
| | | | | | | | | The arguments to SetMem() were wrong. Besides, SetMem() should start at "Dest + Size" since "Size" will be smaller than "Len" if they are not equal. Signed-off-by: Gary Lin <glin@suse.com> Signed-off-by: Nigel Croxon <ncroxon@redhat.com>