Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build with gcc 8 and newer #1

Open
wants to merge 3 commits into
base: UDK2018
Choose a base branch
from

Commits on Sep 29, 2020

  1. BaseTools/header.makefile: add "-Wno-stringop-truncation"

    gcc-8 (which is part of Fedora 28) enables the new warning
    "-Wstringop-truncation" in "-Wall". This warning is documented in detail
    at <https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html>; the
    introduction says
    
    > Warn for calls to bounded string manipulation functions such as strncat,
    > strncpy, and stpncpy that may either truncate the copied string or leave
    > the destination unchanged.
    
    It breaks the BaseTools build with:
    
    > EfiUtilityMsgs.c: In function 'PrintMessage':
    > EfiUtilityMsgs.c:484:9: error: 'strncat' output may be truncated copying
    > between 0 and 511 bytes from a string of length 511
    > [-Werror=stringop-truncation]
    >          strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);
    >          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > EfiUtilityMsgs.c:469:9: error: 'strncat' output may be truncated copying
    > between 0 and 511 bytes from a string of length 511
    > [-Werror=stringop-truncation]
    >          strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);
    >          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > EfiUtilityMsgs.c:511:5: error: 'strncat' output may be truncated copying
    > between 0 and 511 bytes from a string of length 511
    > [-Werror=stringop-truncation]
    >      strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);
    >      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    The right way to fix the warning would be to implement string concat with
    snprintf(). However, Microsoft does not appear to support snprintf()
    before VS2015
    <https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010>,
    so we just have to shut up the warning. The strncat() calls flagged above
    are valid BTW.
    
    Cc: Ard Biesheuvel <[email protected]>
    Cc: Cole Robinson <[email protected]>
    Cc: Liming Gao <[email protected]>
    Cc: Paolo Bonzini <[email protected]>
    Cc: Yonghong Zhu <[email protected]>
    Contributed-under: TianoCore Contribution Agreement 1.1
    Signed-off-by: Laszlo Ersek <[email protected]>
    Reviewed-by: Liming Gao <[email protected]>
    lersek authored and NHellFire committed Sep 29, 2020
    Configuration menu
    Copy the full SHA
    aefbe90 View commit details
    Browse the repository at this point in the history

Commits on Sep 30, 2020

  1. BaseTools/GenVtf: silence false "stringop-overflow" warning with memc…

    …py()
    
    gcc-8 (which is part of Fedora 28) enables the new warning
    "-Wstringop-overflow" in "-Wall". This warning is documented in detail at
    <https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html>; the
    introduction says
    
    > Warn for calls to string manipulation functions such as memcpy and
    > strcpy that are determined to overflow the destination buffer.
    
    It breaks the BaseTools build with:
    
    > GenVtf.c: In function 'ConvertVersionInfo':
    > GenVtf.c:132:7: error: 'strncpy' specified bound depends on the length
    > of the source argument [-Werror=stringop-overflow=]
    >        strncpy (TemStr + 4 - Length, Str, Length);
    >        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > GenVtf.c:130:14: note: length computed here
    >      Length = strlen(Str);
    >               ^~~~~~~~~~~
    
    It is a false positive because, while the bound equals the length of the
    source argument, the destination pointer is moved back towards the
    beginning of the destination buffer by the same amount (and this amount is
    range-checked first, so we can't precede the start of the dest buffer).
    
    Replace both strncpy() calls with memcpy().
    
    Cc: Ard Biesheuvel <[email protected]>
    Cc: Cole Robinson <[email protected]>
    Cc: Liming Gao <[email protected]>
    Cc: Paolo Bonzini <[email protected]>
    Cc: Yonghong Zhu <[email protected]>
    Reported-by: Cole Robinson <[email protected]>
    Contributed-under: TianoCore Contribution Agreement 1.1
    Signed-off-by: Laszlo Ersek <[email protected]>
    Reviewed-by: Liming Gao <[email protected]>
    lersek authored and NHellFire committed Sep 30, 2020
    Configuration menu
    Copy the full SHA
    e408be9 View commit details
    Browse the repository at this point in the history

Commits on Oct 1, 2020

  1. BaseTools tools_def.template: Add GCC link script option in ASLDLINK_…

    …FLAGS
    
    GCC link script is used to discard the unused section data from ELF image.
    ASLDLINK_FLAGS requires it to remove the unnecessary section data, then
    GenFw can be used to retrieve the correct data section from ELF image.
    
    Contributed-under: TianoCore Contribution Agreement 1.1
    Signed-off-by: Liming Gao <[email protected]>
    Cc: Yonghong Zhu <[email protected]>
    Reviewed-by: Yonghong Zhu <[email protected]>
    lgao4 authored and NHellFire committed Oct 1, 2020
    Configuration menu
    Copy the full SHA
    4f249dd View commit details
    Browse the repository at this point in the history