1 //===- OutputSegment.cpp --------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "OutputSegment.h" 10 #include "lld/Common/Memory.h" 11 12 using namespace llvm; 13 using namespace lld; 14 using namespace lld::macho; 15 16 std::vector<OutputSegment *> macho::outputSegments; 17 18 OutputSegment *macho::getOrCreateOutputSegment(StringRef name, uint32_t perms) { 19 for (OutputSegment *os : outputSegments) 20 if (os->name == name) 21 // TODO: assert that os->perms == perms, once we figure out what to do 22 // about default-created segments. 23 return os; 24 25 auto *os = make<OutputSegment>(); 26 os->name = name; 27 os->perms = perms; 28 outputSegments.push_back(os); 29 return os; 30 } 31