This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Testsuite: fix builtin-stringop-chk-1.c for ARM


The test builtin-stringop-chk-1.c fails for arm-none-elf in not producing a warning for the following code:

struct T { char a[8]; char b[4]; char c[10]; } t;
stpcpy (t.c,"Testing..."); /* { dg-warning "will always overflow" "stpcpy" } */


This is because the default ARM behavior is to pad structure members up to a word boundary, as set in arm.h:

#define DEFAULT_STRUCTURE_SIZE_BOUNDARY 32

The stpcpy macro as defined in the included "chk.h" file is checking for buffer overflow using __builtin_object_size:

# define os(ptr) __builtin_object_size (ptr, 0)

Which calculates the size of type T as 24, not 22, and so no overflow is reported.

The attached patch adds the "-mstructure-size-boundary=8" option for ARM targets.

Verified that it fixes the problem on arm-none-elf, and that no regression occurs on powerpc-apple-darwin8.2.0.

OK for mainline?

- Josh


2005-08-25 Josh Conner <jconner@apple.com>


* gcc.dg/builtin-stringop-chk-1.c: Add -mstructure-size- boundary=8
to command-line options for arm-*-* targets.



Attachment: stpcpy_test.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]