diff options
author | Robert Moore <Robert.Moore@intel.com> | 2012-11-02 12:20:30 -0700 |
---|---|---|
committer | Robert Moore <Robert.Moore@intel.com> | 2012-11-02 12:20:30 -0700 |
commit | e13146b9f1552ab7680d1058390f029557f7f119 (patch) | |
tree | 08f34ebe7b726a6e5ecec49a3398ced31e2e0ece | |
parent | b6b0e3adb8a040c024729261d0661f1a0f7947d6 (diff) | |
download | acpica-e13146b9f1552ab7680d1058390f029557f7f119.tar.gz |
Disassembler: Prevent duplicate External() statements.
During generation of external statements, prevent similar pathnames
that are actually duplicates, such as these:
External (\ABCD)
External (ABCD)
Remove all leading '\' characters from pathnames during the external
statement generation so that duplicates will be detected and tossed.
-rw-r--r-- | source/common/dmextern.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/source/common/dmextern.c b/source/common/dmextern.c index d0396fb5a..b4c363b3d 100644 --- a/source/common/dmextern.c +++ b/source/common/dmextern.c @@ -225,6 +225,7 @@ AcpiDmNormalizeParentPrefix ( char *Fullpath; char *ParentPath; ACPI_SIZE Length; + UINT32 Index = 0; if (!Op) @@ -283,6 +284,13 @@ AcpiDmNormalizeParentPrefix ( * for the required dot separator (ParentPath.Path) */ Length++; + + /* For External() statements, we do not want a leading '\' */ + + if (*ParentPath == AML_ROOT_PREFIX) + { + Index = 1; + } } Fullpath = ACPI_ALLOCATE_ZEROED (Length); @@ -297,7 +305,7 @@ AcpiDmNormalizeParentPrefix ( * * Copy the parent path */ - ACPI_STRCAT (Fullpath, ParentPath); + ACPI_STRCPY (Fullpath, &ParentPath[Index]); /* * Add dot separator @@ -444,7 +452,22 @@ AcpiDmAddToExternalList ( return; } - /* Externalize the ACPI path */ + /* + * We don't want External() statements to contain a leading '\'. + * This prevents duplicate external statements of the form: + * + * External (\ABCD) + * External (ABCD) + * + * This would cause a compile time error when the disassembled + * output file is recompiled. + */ + if ((*Path == AML_ROOT_PREFIX) && (Path[1])) + { + Path++; + } + + /* Externalize the ACPI pathname */ Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Path, NULL, &ExternalPath); @@ -453,8 +476,10 @@ AcpiDmAddToExternalList ( return; } - /* Get the full pathname from root if "Path" has a parent prefix */ - + /* + * Get the full pathname from the root if "Path" has one or more + * parent prefixes (^). Note: path will not contain a leading '\'. + */ if (*Path == (UINT8) AML_PARENT_PREFIX) { Fullpath = AcpiDmNormalizeParentPrefix (Op, ExternalPath); |