mirror of
https://github.com/intel/llvm.git
synced 2026-02-02 10:08:59 +08:00
Add a special case for trivial alignment.
Normally to find the offset of a value in a section, we have to compute the value since the alignment is defined on the final address. If the alignment is trivial, we can skip the value computation. This allows us to know the offset even in cases where we cannot yet know the value. llvm-svn: 313777
This commit is contained in:
@@ -71,6 +71,11 @@ uint64_t ExprValue::getSecAddr() const {
|
||||
}
|
||||
|
||||
uint64_t ExprValue::getSectionOffset() const {
|
||||
// If the alignment is trivial, we don't have to compute the full
|
||||
// value to know the offset. This allows this function to succeed in
|
||||
// cases where the output section is not yet known.
|
||||
if (Alignment == 1)
|
||||
return Val;
|
||||
return getValue() - getSecAddr();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user