[llvm] [readobj][AArch64] Parse AArch64 build attributes (PR #124276)

Oliver Stannard via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 06:24:23 PST 2025


================
@@ -0,0 +1,152 @@
+//===-AArch64AttributeParser.cpp-AArch64 Attribute Information Printer-===//
+//
+// 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
+//
+//===------------------------------------------------------------------===//
+
+#include "llvm/Support/AArch64AttributeParser.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/AArch64BuildAttributes.h"
+#include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/raw_ostream.h"
+#include <cstdint>
+
+using namespace llvm;
+
+Error AArch64AttributeParser::parse(ArrayRef<uint8_t> Section,
----------------
ostannard wrote:

This is completely replacing the `parse` function in the base class, which I think makes the design more complicated because there is lots of code now in the base class which is only sometimes used.

I think it would be better to split out parsing of the two sub-classes to parse the ARM-style (also used by other architectures) and AArch64-style (currently AArch64 only, but not guaranteed to remain AArch64-specific). This would leave the base class as an abstract class without an implementation of the `parse` function. The architecture-specific classes can then derive from one of the new classes, depending on which format it uses.

The new `AArch64AttributeParser` implementation also only implements some of the behaviour of `ELFAttributeParser`, for example it does not populate the `attributes` map, so the `getAttributeValue` and `getAttributeString` functions will fail. This should either implement all of the functionality provided by the base class, or the parts not needed for the AArch64-style attributes should be moved to the ARM-style class.

https://github.com/llvm/llvm-project/pull/124276


More information about the llvm-commits mailing list