* ARM enum sizes diagnostic
@ 2007-02-15 11:45 Mark Shinwell
2007-02-15 17:38 ` Nick Clifton
0 siblings, 1 reply; 5+ messages in thread
From: Mark Shinwell @ 2007-02-15 11:45 UTC (permalink / raw)
To: binutils
The diagnostic seen below should be marked as a warning rather
than an error; it is possible for the diagnostic to arise when compiling
with GCC and -fshort-enums in a situation where the values of such
short enumerations cannot escape the compilation unit. It is in
fact already treated as a warning rather than an error as seen below.
OK to apply?
Mark
--
2007-02-15 Mark Shinwell <shinwell@codesourcery.com>
bfd/
* elf32-arm.c (elf32_arm_merge_eabi_attributes): Upon discovery
of incompatible EABI attributes for the sizes of enumerations,
diagnose "Warning" not "ERROR".
--- elf32-arm.c 29 Jan 2007 16:29:21 -0000 1.104
+++ elf32-arm.c 15 Feb 2007 11:37:26 -0000
@@ -7201,7 +7201,7 @@ elf32_arm_merge_eabi_attributes (bfd *ib
&& out_attr[i].i != in_attr[i].i)
{
_bfd_error_handler
- (_("ERROR: %B: Conflicting enum sizes"), ibfd);
+ (_("Warning: %B: Conflicting enum sizes"), ibfd);
}
}
break;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ARM enum sizes diagnostic
2007-02-15 11:45 ARM enum sizes diagnostic Mark Shinwell
@ 2007-02-15 17:38 ` Nick Clifton
2007-02-15 20:30 ` Mark Shinwell
2007-03-18 22:22 ` Mark Shinwell
0 siblings, 2 replies; 5+ messages in thread
From: Nick Clifton @ 2007-02-15 17:38 UTC (permalink / raw)
To: Mark Shinwell; +Cc: binutils
Hi Mark,
> The diagnostic seen below should be marked as a warning rather
> than an error; it is possible for the diagnostic to arise when compiling
> with GCC and -fshort-enums in a situation where the values of such
> short enumerations cannot escape the compilation unit. It is in
> fact already treated as a warning rather than an error as seen below.
This is OK, but if you are going to fix this message then you might as
well go the whole hog. Specifically:
* Report the two enum sizes.
* Explain to the user why this might not be a problem.
So maybe something like this:
warning: <foo.o> places 'enum' values into <N> bytes whereas
<bar.o> places them into <M> bytes. This will cause problems
if the two files attempt to share enum values.
You may also want to think about having a way of disabling this warning
message for users that do not want it.
Cheers
Nick
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ARM enum sizes diagnostic
2007-02-15 17:38 ` Nick Clifton
@ 2007-02-15 20:30 ` Mark Shinwell
2007-03-18 22:22 ` Mark Shinwell
1 sibling, 0 replies; 5+ messages in thread
From: Mark Shinwell @ 2007-02-15 20:30 UTC (permalink / raw)
To: Nick Clifton; +Cc: binutils
Nick Clifton wrote:
> Hi Mark,
>
>> The diagnostic seen below should be marked as a warning rather
>> than an error; it is possible for the diagnostic to arise when compiling
>> with GCC and -fshort-enums in a situation where the values of such
>> short enumerations cannot escape the compilation unit. It is in
>> fact already treated as a warning rather than an error as seen below.
>
> This is OK, but if you are going to fix this message then you might as
> well go the whole hog. Specifically:
>
> * Report the two enum sizes.
> * Explain to the user why this might not be a problem.
>
> So maybe something like this:
>
> warning: <foo.o> places 'enum' values into <N> bytes whereas
> <bar.o> places them into <M> bytes. This will cause problems
> if the two files attempt to share enum values.
>
> You may also want to think about having a way of disabling this warning
> message for users that do not want it.
Agreed on both counts; I'll work on that.
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ARM enum sizes diagnostic
2007-02-15 17:38 ` Nick Clifton
2007-02-15 20:30 ` Mark Shinwell
@ 2007-03-18 22:22 ` Mark Shinwell
2007-03-20 12:40 ` Nick Clifton
1 sibling, 1 reply; 5+ messages in thread
From: Mark Shinwell @ 2007-03-18 22:22 UTC (permalink / raw)
To: Nick Clifton; +Cc: binutils
Nick Clifton wrote:
>> The diagnostic seen below should be marked as a warning rather
>> than an error; it is possible for the diagnostic to arise when compiling
>> with GCC and -fshort-enums in a situation where the values of such
>> short enumerations cannot escape the compilation unit. It is in
>> fact already treated as a warning rather than an error as seen below.
>
> This is OK, but if you are going to fix this message then you might as
> well go the whole hog. Specifically:
>
> * Report the two enum sizes.
> * Explain to the user why this might not be a problem.
>
> So maybe something like this:
>
> warning: <foo.o> places 'enum' values into <N> bytes whereas
> <bar.o> places them into <M> bytes. This will cause problems
> if the two files attempt to share enum values.
>
> You may also want to think about having a way of disabling this warning
> message for users that do not want it.
The following (which has taken rather more time than it was worth,
I think :-) is about as good as we can do, since we can't pinpoint
N and M precisely. It behaves as expected in manual testing.
OK to apply?
Mark
--
2007-03-18 Mark Shinwell <shinwell@codesourcery.com>
bfd/
* bfd-in.h (bfd_elf32_arm_set_target_relocs): Add "bfd *"
argument and extra last argument.
* bfd-in2.h: Regenerate.
* elf32-arm.c (elf32_arm_obj_tdata): Add no_enum_size_warning
member.
(bfd_elf32_arm_set_target_relocs): Add "bfd *" argument and
extra last argument. Set no_enum_size_warning appropriately.
(elf32_arm_merge_eabi_attributes): Improve enum sizes
diagnostic, suppressing it when no_enum_size_warning dictates.
ld/
* ld.texinfo: Document --no-enum-size-warning.
* emultempl/armelf.em (no_enum_size_warning): New.
(arm_elf_create_output_section_statements): Correct typo
in comment. Pass no_enum_size_warning to
bfd_elf32_arm_set_target_relocs.
(PARSE_AND_LIST_PROLOGUE): Define OPTION_NO_ENUM_SIZE_WARNING.
(PARSE_AND_LIST_OPTIONS): Document --no-enum-size-warning.
(PARSE_AND_LIST_ARGS_CASES): Add OPTION_NO_ENUM_SIZE_WARNING
case.
Index: bfd/bfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in.h,v
retrieving revision 1.123
diff -U3 -p -r1.123 bfd-in.h
--- bfd/bfd-in.h 29 Jan 2007 16:29:21 -0000 1.123
+++ bfd/bfd-in.h 18 Mar 2007 22:14:55 -0000
@@ -895,7 +895,8 @@ extern bfd_boolean bfd_elf32_arm_process
(bfd *, struct bfd_link_info *);
void bfd_elf32_arm_set_target_relocs
- (struct bfd_link_info *, int, char *, int, int, bfd_arm_vfp11_fix);
+ (bfd *, struct bfd_link_info *, int, char *, int, int, bfd_arm_vfp11_fix,
+ int);
extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
(bfd *, struct bfd_link_info *);
Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.414
diff -U3 -p -r1.414 bfd-in2.h
--- bfd/bfd-in2.h 5 Feb 2007 19:50:11 -0000 1.414
+++ bfd/bfd-in2.h 18 Mar 2007 22:14:55 -0000
@@ -902,7 +902,8 @@ extern bfd_boolean bfd_elf32_arm_process
(bfd *, struct bfd_link_info *);
void bfd_elf32_arm_set_target_relocs
- (struct bfd_link_info *, int, char *, int, int, bfd_arm_vfp11_fix);
+ (bfd *, struct bfd_link_info *, int, char *, int, int, bfd_arm_vfp11_fix,
+ int);
extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
(bfd *, struct bfd_link_info *);
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.105
diff -U3 -p -r1.105 elf32-arm.c
--- bfd/elf32-arm.c 22 Feb 2007 17:03:59 -0000 1.105
+++ bfd/elf32-arm.c 18 Mar 2007 22:14:55 -0000
@@ -2064,6 +2064,9 @@ struct elf32_arm_obj_tdata
aeabi_attribute known_eabi_attributes[NUM_KNOWN_ATTRIBUTES];
aeabi_attribute_list *other_eabi_attributes;
+
+ /* Zero to warn when linking objects with incompatible enum sizes. */
+ int no_enum_size_warning;
};
#define elf32_arm_tdata(abfd) \
@@ -3858,12 +3861,14 @@ bfd_elf32_arm_vfp11_fix_veneer_locations
/* Set target relocation values needed during linking. */
void
-bfd_elf32_arm_set_target_relocs (struct bfd_link_info *link_info,
+bfd_elf32_arm_set_target_relocs (struct bfd *output_bfd,
+ struct bfd_link_info *link_info,
int target1_is_rel,
char * target2_type,
int fix_v4bx,
int use_blx,
- bfd_arm_vfp11_fix vfp11_fix)
+ bfd_arm_vfp11_fix vfp11_fix,
+ int no_enum_warn)
{
struct elf32_arm_link_hash_table *globals;
@@ -3884,6 +3889,8 @@ bfd_elf32_arm_set_target_relocs (struct
globals->fix_v4bx = fix_v4bx;
globals->use_blx |= use_blx;
globals->vfp11_fix = vfp11_fix;
+
+ elf32_arm_tdata (output_bfd)->no_enum_size_warning = no_enum_warn;
}
/* The thumb form of a long branch is a bit finicky, because the offset
@@ -7198,10 +7205,15 @@ elf32_arm_merge_eabi_attributes (bfd *ib
out_attr[i].i = in_attr[i].i;
}
else if (in_attr[i].i != AEABI_enum_forced_wide
- && out_attr[i].i != in_attr[i].i)
+ && out_attr[i].i != in_attr[i].i
+ && !elf32_arm_tdata (obfd)->no_enum_size_warning)
{
+ const char *aeabi_enum_names[] =
+ { "", "variable-size", "32-bit", "" };
_bfd_error_handler
- (_("ERROR: %B: Conflicting enum sizes"), ibfd);
+ (_("warning: %B uses %s enums yet the output is to use
%s enums; use of enum values across objects may fail"),
+ ibfd, aeabi_enum_names[in_attr[i].i],
+ aeabi_enum_names[out_attr[i].i]);
}
}
break;
Index: ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.184
diff -U3 -p -r1.184 ld.texinfo
--- ld/ld.texinfo 29 Jan 2007 16:28:40 -0000 1.184
+++ ld/ld.texinfo 18 Mar 2007 22:14:56 -0000
@@ -5519,6 +5519,15 @@ instruction. The original instruction is
the veneer. The extra cycles required to call and return from the veneer
are sufficient to avoid the erratum in both the scalar and vector cases.
+@cindex NO_ENUM_SIZE_WARNING
+@kindex --no-enum-size-warning
+The @samp{--no-enum-size-warning} switch prevents the linker from
+warning when linking object files that specify incompatible EABI
+enumeration size attributes. For example, with this switch enabled,
+linking of an object file using 32-bit enumeration values with another
+using enumeration values fitted into the smallest possible space will
+not be diagnosed.
+
@ifclear GENERIC
@lowersections
@end ifclear
Index: ld/emultempl/armelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/armelf.em,v
retrieving revision 1.53
diff -U3 -p -r1.53 armelf.em
--- ld/emultempl/armelf.em 29 Jan 2007 16:28:40 -0000 1.53
+++ ld/emultempl/armelf.em 18 Mar 2007 22:14:56 -0000
@@ -36,6 +36,7 @@ static char *target2_type = "${TARGET2_T
static int fix_v4bx = 0;
static int use_blx = 0;
static bfd_arm_vfp11_fix vfp11_denorm_fix = BFD_ARM_VFP11_FIX_DEFAULT;
+static int no_enum_size_warning = 0;
static void
gld${EMULATION_NAME}_before_parse (void)
@@ -233,13 +234,14 @@ arm_elf_finish (void)
thumb_entry_symbol);
}
-/* This is a convenitent point to tell BFD about target specific flags.
+/* This is a convenient point to tell BFD about target specific flags.
After the output has been created, but before inputs are read. */
static void
arm_elf_create_output_section_statements (void)
{
- bfd_elf32_arm_set_target_relocs (&link_info, target1_is_rel, target2_type,
- fix_v4bx, use_blx, vfp11_denorm_fix);
+ bfd_elf32_arm_set_target_relocs (output_bfd, &link_info, target1_is_rel,
+ target2_type, fix_v4bx, use_blx,
+ vfp11_denorm_fix, no_enum_size_warning);
}
EOF
@@ -256,6 +258,7 @@ PARSE_AND_LIST_PROLOGUE='
#define OPTION_FIX_V4BX 306
#define OPTION_USE_BLX 307
#define OPTION_VFP11_DENORM_FIX 308
+#define OPTION_NO_ENUM_SIZE_WARNING 309
'
PARSE_AND_LIST_SHORTOPTS=p
@@ -270,6 +273,7 @@ PARSE_AND_LIST_LONGOPTS='
{ "fix-v4bx", no_argument, NULL, OPTION_FIX_V4BX},
{ "use-blx", no_argument, NULL, OPTION_USE_BLX},
{ "vfp11-denorm-fix", required_argument, NULL, OPTION_VFP11_DENORM_FIX},
+ { "no-enum-size-warning", no_argument, NULL, OPTION_NO_ENUM_SIZE_WARNING},
'
PARSE_AND_LIST_OPTIONS='
@@ -281,6 +285,7 @@ PARSE_AND_LIST_OPTIONS='
fprintf (file, _(" --fix-v4bx Rewrite BX rn as MOV
pc, rn for ARMv4\n"));
fprintf (file, _(" --use-blx Enable use of BLX
instructions\n"));
fprintf (file, _(" --vfp11-denorm-fix Specify how to fix
VFP11 denorm erratum\n"));
+ fprintf (file, _(" --no-enum-size-warning Don'\''t warn about
objects with incompatible enum sizes\n"));
'
PARSE_AND_LIST_ARGS_CASES='
@@ -326,6 +331,10 @@ PARSE_AND_LIST_ARGS_CASES='
else
einfo (_("Unrecognized VFP11 fix type '\''%s'\''.\n"), optarg);
break;
+
+ case OPTION_NO_ENUM_SIZE_WARNING:
+ no_enum_size_warning = 1;
+ break;
'
# We have our own after_open and before_allocation functions, but they call
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ARM enum sizes diagnostic
2007-03-18 22:22 ` Mark Shinwell
@ 2007-03-20 12:40 ` Nick Clifton
0 siblings, 0 replies; 5+ messages in thread
From: Nick Clifton @ 2007-03-20 12:40 UTC (permalink / raw)
To: Mark Shinwell; +Cc: binutils
Hi Mark,
> 2007-03-18 Mark Shinwell <shinwell@codesourcery.com>
>
> bfd/
> * bfd-in.h (bfd_elf32_arm_set_target_relocs): Add "bfd *"
> argument and extra last argument.
> * bfd-in2.h: Regenerate.
> * elf32-arm.c (elf32_arm_obj_tdata): Add no_enum_size_warning
> member.
> (bfd_elf32_arm_set_target_relocs): Add "bfd *" argument and
> extra last argument. Set no_enum_size_warning appropriately.
> (elf32_arm_merge_eabi_attributes): Improve enum sizes
> diagnostic, suppressing it when no_enum_size_warning dictates.
>
> ld/
> * ld.texinfo: Document --no-enum-size-warning.
> * emultempl/armelf.em (no_enum_size_warning): New.
> (arm_elf_create_output_section_statements): Correct typo
> in comment. Pass no_enum_size_warning to
> bfd_elf32_arm_set_target_relocs.
> (PARSE_AND_LIST_PROLOGUE): Define OPTION_NO_ENUM_SIZE_WARNING.
> (PARSE_AND_LIST_OPTIONS): Document --no-enum-size-warning.
> (PARSE_AND_LIST_ARGS_CASES): Add OPTION_NO_ENUM_SIZE_WARNING
> case.
Approved - please apply.
Cheers
Nick
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-03-20 12:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-15 11:45 ARM enum sizes diagnostic Mark Shinwell
2007-02-15 17:38 ` Nick Clifton
2007-02-15 20:30 ` Mark Shinwell
2007-03-18 22:22 ` Mark Shinwell
2007-03-20 12:40 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).