llvm-capstone/lld/MachO/MachOStructs.h
Jez Ng 1e1a3f67ee [lld-macho] Ensure reads from nlist_64 structs are aligned when necessary
My test refactoring in D80217 seems to have caused yaml2obj to emit
unaligned nlist_64 structs, causing ASAN'd lld to be unhappy. I don't
think this is an issue with yaml2obj though -- llvm-mc also seems to
emit unaligned nlist_64s. This diff makes lld able to safely do aligned
reads under ASAN builds while hopefully creating no overhead for regular
builds on architectures that support unaligned reads.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D80414
2020-06-02 13:19:38 -07:00

37 lines
1.0 KiB
C++

//===- MachOStructs.h -------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines structures used in the MachO object file format. Note that
// unlike llvm/BinaryFormat/MachO.h, the structs here are defined in terms of
// endian- and alignment-compatibility wrappers.
//
//===----------------------------------------------------------------------===//
#ifndef LLD_MACHO_MACHO_STRUCTS_H
#define LLD_MACHO_MACHO_STRUCTS_H
#include "llvm/Support/Endian.h"
namespace lld {
namespace structs {
struct nlist_64 {
llvm::support::ulittle32_t n_strx;
uint8_t n_type;
uint8_t n_sect;
llvm::support::ulittle16_t n_desc;
llvm::support::ulittle64_t n_value;
};
} // namespace structs
} // namespace lld
#endif