-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Reapply "Allow "[[FLAGS=<none>]]" value in the ELF Fileheader Flags field (#143845)" #151094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| ## Check how obj2yaml dumps e_flags field. | ||
|
|
||
| --- !ELF | ||
| FileHeader: | ||
| Class: ELFCLASS64 | ||
| Data: ELFDATA2MSB | ||
| Type: ET_EXEC | ||
| Machine: EM_SPARC32PLUS | ||
| Flags: [ [[FLAGS]] ] | ||
|
|
||
| # RUN: yaml2obj -DFLAGS="EF_SPARC_32PLUS " %s -o %t2 | ||
| # RUN: obj2yaml %t2 | FileCheck %s --check-prefix=FLAG | ||
|
|
||
| # FLAG: --- !ELF | ||
| # FLAG-NEXT: FileHeader: | ||
| # FLAG-NEXT: Class: ELFCLASS64 | ||
| # FLAG-NEXT: Data: ELFDATA2MSB | ||
| # FLAG-NEXT: Type: ET_EXEC | ||
| # FLAG-NEXT: Machine: EM_SPARC32PLUS | ||
| # FLAG-NEXT: Flags: [ EF_SPARC_32PLUS ] | ||
|
|
||
| # RUN: yaml2obj -DFLAGS="EF_SPARC_HAL_R1 " %s -o %t3 | ||
| # RUN: obj2yaml %t3 | FileCheck %s --check-prefix=FLAG2 | ||
|
|
||
| # FLAG2: --- !ELF | ||
| # FLAG2-NEXT: FileHeader: | ||
| # FLAG2-NEXT: Class: ELFCLASS64 | ||
| # FLAG2-NEXT: Data: ELFDATA2MSB | ||
| # FLAG2-NEXT: Type: ET_EXEC | ||
| # FLAG2-NEXT: Machine: EM_SPARC32PLUS | ||
| # FLAG2-NEXT: Flags: [ EF_SPARC_HAL_R1 ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| ## Test for FileHeader Flags. | ||
|
|
||
| ## When FLAGS variable isn't defined, the e_flags value is 0. | ||
| ## Otherwise, it's the specified value. | ||
|
|
||
| # RUN: yaml2obj %s -o %t | ||
| # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=NO-FLAG | ||
|
|
||
| # RUN: yaml2obj %s -o %t -DFLAGS=[EF_SPARC_32PLUS] | ||
| # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=FLAG | ||
|
|
||
| !ELF | ||
| FileHeader: | ||
| Class: ELFCLASS32 | ||
| Data: ELFDATA2LSB | ||
| Type: ET_EXEC | ||
| Machine: EM_SPARC32PLUS | ||
| Flags: [[FLAGS=<none>]] | ||
|
|
||
| # NO-FLAG: Flags [ (0x0) | ||
| # NO-FLAG-NEXT: ] | ||
|
|
||
| # FLAG: Flags [ (0x100) | ||
| # FLAG-NEXT: EF_SPARC_32PLUS (0x100) | ||
| # FLAG-NEXT: ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -281,7 +281,8 @@ template <class ELFT> Expected<ELFYAML::Object *> ELFDumper<ELFT>::dump() { | |
| Y->Header.Type = Obj.getHeader().e_type; | ||
| if (Obj.getHeader().e_machine != 0) | ||
| Y->Header.Machine = ELFYAML::ELF_EM(Obj.getHeader().e_machine); | ||
| Y->Header.Flags = Obj.getHeader().e_flags; | ||
| if (Obj.getHeader().e_flags != 0) | ||
| Y->Header.Flags = ELFYAML::ELF_EF(Obj.getHeader().e_flags); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line changed too it seems. We need a cast here now?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This cast will ensure we generate a Flags output everytime.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to make much sense to me. The line above it ( So, what is the cast doing and could you give an example where the behaviour has changed with this case, please?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the old patch on a release build I found all lit tests passing but with assertions enabled it was causing a lot of tests to crash.
|
||
| Y->Header.Entry = Obj.getHeader().e_entry; | ||
|
|
||
| // Dump sections | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an addition from the original PR applied right? How does this fix the test failures?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're removing the default value and making it truly optional.