llvm/lld/wasm/SyntheticSections.h

//===- SyntheticSection.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
//
//===----------------------------------------------------------------------===//
//
// Synthetic sections represent chunks of linker-created data. If you
// need to create a chunk of data that to be included in some section
// in the result, you probably want to create that as a synthetic section.
//
//===----------------------------------------------------------------------===//

#ifndef LLD_WASM_SYNTHETIC_SECTIONS_H
#define LLD_WASM_SYNTHETIC_SECTIONS_H

#include "OutputSections.h"

#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/BinaryFormat/WasmTraits.h"
#include <optional>

#define DEBUG_TYPE

namespace lld::wasm {

// An init entry to be written to either the synthetic init func or the
// linking metadata.
struct WasmInitEntry {};

class SyntheticSection : public OutputSection {};

// Create the custom "dylink" section containing information for the dynamic
// linker.
// See
// https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
class DylinkSection : public SyntheticSection {};

class TypeSection : public SyntheticSection {};

/**
 * A key for some kind of imported entity of type `T`.
 *
 * Used when de-duplicating imports.
 */
template <typename T> struct ImportKey {};

template <typename T>
inline bool operator==(const ImportKey<T> &lhs, const ImportKey<T> &rhs) {}

} // namespace wasm::lld

// `ImportKey<T>` can be used as a key in a `DenseMap` if `T` can be used as a
// key in a `DenseMap`.
namespace llvm {
DenseMapInfo<lld::wasm::ImportKey<T>>;
} // end namespace llvm

namespace lld {
namespace wasm {

class ImportSection : public SyntheticSection {};

class FunctionSection : public SyntheticSection {};

class TableSection : public SyntheticSection {};

class MemorySection : public SyntheticSection {};

// The tag section contains a list of declared wasm tags associated with the
// module. Currently the only supported tag kind is exceptions. All C++
// exceptions are represented by a single tag. A tag entry in this section
// contains information on what kind of tag it is (e.g. exception) and the type
// of values associated with the tag. (In Wasm, a tag can contain multiple
// values of primitive types. But for C++ exceptions, we just throw a pointer
// which is an i32 value (for wasm32 architecture), so the signature of C++
// exception is (i32)->(void), because all exception tag types are assumed to
// have void return type to share WasmSignature with functions.)
class TagSection : public SyntheticSection {};

class GlobalSection : public SyntheticSection {};

class ExportSection : public SyntheticSection {};

class StartSection : public SyntheticSection {};

class ElemSection : public SyntheticSection {};

class DataCountSection : public SyntheticSection {};

// Create the custom "linking" section containing linker metadata.
// This is only created when relocatable output is requested.
class LinkingSection : public SyntheticSection {};

// Create the custom "name" section containing debug symbol names.
class NameSection : public SyntheticSection {};

class ProducersSection : public SyntheticSection {};

class TargetFeaturesSection : public SyntheticSection {};

class RelocSection : public SyntheticSection {};

class BuildIdSection : public SyntheticSection {};

// Linker generated output sections
struct OutStruct {};

extern OutStruct out;

} // namespace wasm
} // namespace lld

#endif