This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Allow uppercase section directives
AbandonedPublic

Authored by sidneym on Mar 17 2020, 2:46 PM.

Details

Summary

It was noticed that llvm-mc doesn't allow uppercase section directives. I don't see any obvious reason why they shouldn't be allowed.

Since this has never been the case for llvm I'm not sure how important this is but gnu-as isn't case sensative AFAIK.

Diff Detail

Event Timeline

sidneym created this revision.Mar 17 2020, 2:46 PM
Herald added a project: Restricted Project. · View Herald Transcript

Seems I do not understand the current behavior.

GNU as shows the following errors for this test:

test.s:6: Error: unknown pseudo-op: `.data.rel.ro'
test.s:9: Error: unknown pseudo-op: `.data.rel'
test.s:12: Error: unknown pseudo-op: `.eh_frame'
test.s:15: Error: unknown pseudo-op: `.rodata'
test.s:18: Error: unknown pseudo-op: `.tbss'
test.s:21: Error: unknown pseudo-op: `.tdata'
test.s:27: Error: unknown pseudo-op: `.data.rel.ro'
test.s:30: Error: unknown pseudo-op: `.data.rel'
test.s:33: Error: unknown pseudo-op: `.eh_frame'
test.s:36: Error: unknown pseudo-op: `.rodata'
test.s:39: Error: unknown pseudo-op: `.tbss'
test.s:42: Error: unknown pseudo-op: `.tdata'

Looking at the documentation of directives allowed (https://sourceware.org/binutils/docs/as/Pseudo-Ops.html#Pseudo-Ops)
It says: "The names are case insensitive for most targets, and usually written in lower case."
But it mentions only Data and Text directives. Though we do not check them in this test (but we support them).

So seems we are already different here. But does it make sence to support upper-case? I do not know.
Perhaps it is OK for the compatibility (with the spec), but seems we have no users, so probably we shouldn't?
I'd like to hear what other think.

Seems I do not understand the current behavior.

GNU as shows the following errors for this test:

test.s:6: Error: unknown pseudo-op: `.data.rel.ro'
test.s:9: Error: unknown pseudo-op: `.data.rel'
test.s:12: Error: unknown pseudo-op: `.eh_frame'
test.s:15: Error: unknown pseudo-op: `.rodata'
test.s:18: Error: unknown pseudo-op: `.tbss'
test.s:21: Error: unknown pseudo-op: `.tdata'
test.s:27: Error: unknown pseudo-op: `.data.rel.ro'
test.s:30: Error: unknown pseudo-op: `.data.rel'
test.s:33: Error: unknown pseudo-op: `.eh_frame'
test.s:36: Error: unknown pseudo-op: `.rodata'
test.s:39: Error: unknown pseudo-op: `.tbss'
test.s:42: Error: unknown pseudo-op: `.tdata'

I think GNU might want a leading .section.

Looking at the documentation of directives allowed (https://sourceware.org/binutils/docs/as/Pseudo-Ops.html#Pseudo-Ops)
It says: "The names are case insensitive for most targets, and usually written in lower case."
But it mentions only `Data` and `Text` directives. Though we do not check them in this test (but we support them).

So seems we are already different here. But does it make sence to support upper-case? I do not know.
Perhaps it is OK for the compatibility (with the spec), but seems we have no users, so probably we shouldn't?
I'd like to hear what other think.

That is fair, I ran accross some code that was all uppercase and the .TEXT section was actually the error that surfaced. I will update the testcase to include all of the ops if we want to add this patch.

MaskRay requested changes to this revision.EditedMar 18 2020, 8:58 AM

I am mostly with the following opinions.

http://lists.llvm.org/pipermail/llvm-dev/2020-February/138955.html @JonChesterfield: This doesn't sound right. GNU binutils have a large quantity of legacy cruft, not least the redundancy between tools like readelf and objdump which are capable of doing the same task in exchange for different command line arguments.

@joerg: So given that we got around with this for years, how much use do non-lower case assembler pseudops actually see?

Can't the projects using uppercase directives be fixed?

I don't see any obvious reason why they shouldn't be allowed.

Most people agree this is legacy cruft. There is few if any project which must use this syntax. I think we need a very strong reason to support uppercase directives, rather than the converse.

(https://bugs.llvm.org/show_bug.cgi?id=39527 was really a bad example. The author committed one change, despite the request both on the differential and on the bugzilla, they continued making another change with no explanation (bugzilla,differential,or git commit description).)

This revision now requires changes to proceed.Mar 18 2020, 8:58 AM

Seems I do not understand the current behavior.

GNU as shows the following errors for this test:

test.s:6: Error: unknown pseudo-op: `.data.rel.ro'
test.s:9: Error: unknown pseudo-op: `.data.rel'
test.s:12: Error: unknown pseudo-op: `.eh_frame'
test.s:15: Error: unknown pseudo-op: `.rodata'
test.s:18: Error: unknown pseudo-op: `.tbss'
test.s:21: Error: unknown pseudo-op: `.tdata'
test.s:27: Error: unknown pseudo-op: `.data.rel.ro'
test.s:30: Error: unknown pseudo-op: `.data.rel'
test.s:33: Error: unknown pseudo-op: `.eh_frame'
test.s:36: Error: unknown pseudo-op: `.rodata'
test.s:39: Error: unknown pseudo-op: `.tbss'
test.s:42: Error: unknown pseudo-op: `.tdata'

Looking at the documentation of directives allowed (https://sourceware.org/binutils/docs/as/Pseudo-Ops.html#Pseudo-Ops)
It says: "The names are case insensitive for most targets, and usually written in lower case."
But it mentions only Data and Text directives. Though we do not check them in this test (but we support them).

So seems we are already different here. But does it make sence to support upper-case? I do not know.
Perhaps it is OK for the compatibility (with the spec), but seems we have no users, so probably we shouldn't?
I'd like to hear what other think.

The extra recognized special sections can be considered extensions. If they don't seem to cause error-prone behaviors (other than portability issues), I think we probably don't need to write more code just to reject them.

sidneym abandoned this revision.Mar 18 2020, 10:04 AM

OK, I will drop it. Thanks