Skip to content

Inclusion of nlohmann/json.hpp causes OS/ABI to change on Linux #1410

Description

@jongough
  • What is the issue you have?
    Trying to incorporate a json schema validator using nlohmann/json.hpp into C++ code causes the linux gcc compiler/linker to change the OSABI from UNIX - System V (ELF OS/ABI value 0) to UNIX - GNU (ELF OS/ABI value 3). This makes it impossible to run with existing programs as it fails the compliance test at runtime.

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?
    A simple program called testOSABI.cpp:

    //#include "nlohmann/json.hpp"
    int main (){
        return 0;
    }

If compiled with:
gcc testOSABI.cpp -o testOSABI.o -Inlohmann_json/single_include
Then use readelf
readelf -h testOSABI.o
will give:

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x4f0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          6376 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         28
  Section header string table index: 27

If the program has the #include statement uncommented and the same process followed the readelf will give:

  Magic:   7f 45 4c 46 02 01 01 03 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - GNU
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x520
  Start of program headers:          64 (bytes into file)
  Start of section headers:          7032 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         29
  Section header string table index: 28
  • What is the expected behaviour?
    The two outputs should be the same for the OS/ABI value

  • And what is the actual behaviour instead?
    The two OS/ABI values are different. This will stop a program with json.hpp included from interacting successfully with one that does not have json.hpp included.

  • Which compiler and operating system are you using? Is it a supported compiler?
    gcc 7.3.0 on Ubuntu based Linux Mint 19 with kernel 4.18.0-13-generic

  • Did you use a released version of the library or the version from the develop branch?
    Release

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: help neededthe issue needs help to proceedstate: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updated

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions