binutils/binutils-2.24-set-section-macros.patch

104 lines
4.0 KiB
Diff
Raw Normal View History

diff -rcp ../binutils-2.24.orig/bfd/bfd-in2.h bfd/bfd-in2.h
*** ../binutils-2.24.orig/bfd/bfd-in2.h 2014-04-22 12:03:35.226872578 +0100
--- bfd/bfd-in2.h 2014-04-22 12:07:51.556393678 +0100
*************** typedef struct bfd_section *sec_ptr;
*** 294,302 ****
#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
- #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
- #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
- #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
/* Find the address one past the end of SEC. */
#define bfd_get_section_limit(bfd, sec) \
(((bfd)->direction != write_direction && (sec)->rawsize != 0 \
--- 294,299 ----
*************** struct relax_table {
*** 1592,1597 ****
--- 1589,1620 ----
int size;
};
+ /* Note: the following are provided as inline functions rather than macros
+ because not all callers use the return value. A macro implementation
+ would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some
+ compilers will complain about comma expressions that have no effect. */
+ static inline bfd_boolean
+ bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val)
+ {
+ ptr->userdata = val;
+ return TRUE;
+ }
+
+ static inline bfd_boolean
+ bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val)
+ {
+ ptr->vma = ptr->lma = val;
+ ptr->user_set_vma = TRUE;
+ return TRUE;
+ }
+
+ static inline bfd_boolean
+ bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val)
+ {
+ ptr->alignment_power = val;
+ return TRUE;
+ }
+
/* These sections are global, and are managed by BFD. The application
and target back end are not permitted to change the values in
these sections. */
diff -rcp ../binutils-2.24.orig/bfd/bfd-in.h bfd/bfd-in.h
*** ../binutils-2.24.orig/bfd/bfd-in.h 2014-04-22 12:03:35.272868967 +0100
--- bfd/bfd-in.h 2014-04-22 12:06:12.850914084 +0100
*************** typedef struct bfd_section *sec_ptr;
*** 287,295 ****
#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
- #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
- #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
- #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
/* Find the address one past the end of SEC. */
#define bfd_get_section_limit(bfd, sec) \
(((bfd)->direction != write_direction && (sec)->rawsize != 0 \
--- 287,292 ----
diff -rcp ../binutils-2.24.orig/bfd/section.c bfd/section.c
*** ../binutils-2.24.orig/bfd/section.c 2014-04-22 12:03:35.215873442 +0100
--- bfd/section.c 2014-04-22 12:06:55.795118059 +0100
*************** CODE_FRAGMENT
*** 542,547 ****
--- 542,573 ----
. int size;
.};
.
+ .{* Note: the following are provided as inline functions rather than macros
+ . because not all callers use the return value. A macro implementation
+ . would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some
+ . compilers will complain about comma expressions that have no effect. *}
+ .static inline bfd_boolean
+ .bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val)
+ .{
+ . ptr->userdata = val;
+ . return TRUE;
+ .}
+ .
+ .static inline bfd_boolean
+ .bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val)
+ .{
+ . ptr->vma = ptr->lma = val;
+ . ptr->user_set_vma = TRUE;
+ . return TRUE;
+ .}
+ .
+ .static inline bfd_boolean
+ .bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val)
+ .{
+ . ptr->alignment_power = val;
+ . return TRUE;
+ .}
+ .
.{* These sections are global, and are managed by BFD. The application
. and target back end are not permitted to change the values in
. these sections. *}