* [gold patch] Fix C++11 warnings
@ 2011-12-17 0:14 Cary Coutant
2011-12-17 1:53 ` Ian Lance Taylor
0 siblings, 1 reply; 4+ messages in thread
From: Cary Coutant @ 2011-12-17 0:14 UTC (permalink / raw)
To: Ian Lance Taylor, Binutils
This patch fixes several places where C++11 issues a warning about narrowing.
Tested on x86_64. OK?
-cary
2011-12-16 Cary Coutant <ccoutant@google.com>
* dwarf_reader.cc (Sized_dwarf_line_info::read_lines): Add casts.
* i386.cc (Target_i386::do_code_fill): Use char constants for nop
arrays.
* x86_64.cc (Target_x86_64::do_code_fill): Likewise.
Index: dwarf_reader.cc
===================================================================
RCS file: /cvs/src/src/gold/dwarf_reader.cc,v
retrieving revision 1.33
diff -u -p -r1.33 dwarf_reader.cc
--- dwarf_reader.cc 5 Apr 2011 19:19:42 -0000 1.33
+++ dwarf_reader.cc 17 Dec 2011 00:09:45 -0000
@@ -491,8 +491,10 @@ Sized_dwarf_line_info<size, big_endian>:
&& (shndx == -1U || lsm.shndx == -1U || shndx == lsm.shndx))
{
Offset_to_lineno_entry entry
- = { lsm.address, this->current_header_index_,
- lsm.file_num, true, lsm.line_num };
+ = { static_cast<off_t>(lsm.address),
+ this->current_header_index_,
+ static_cast<unsigned int>(lsm.file_num),
+ true, lsm.line_num };
std::vector<Offset_to_lineno_entry>&
map(this->line_number_map_[lsm.shndx]);
// If we see two consecutive entries with the same
Index: i386.cc
===================================================================
RCS file: /cvs/src/src/gold/i386.cc,v
retrieving revision 1.142
diff -u -p -r1.142 i386.cc
--- i386.cc 31 Oct 2011 22:33:04 -0000 1.142
+++ i386.cc 17 Dec 2011 00:09:45 -0000
@@ -3474,42 +3474,51 @@ Target_i386::do_code_fill(section_size_t
}
// Nop sequences of various lengths.
- const char nop1[1] = { 0x90 }; // nop
- const char nop2[2] = { 0x66, 0x90 }; // xchg %ax %ax
- const char nop3[3] = { 0x8d, 0x76, 0x00 }; // leal 0(%esi),%esi
- const char nop4[4] = { 0x8d, 0x74, 0x26, 0x00}; // leal 0(%esi,1),%esi
- const char nop5[5] = { 0x90, 0x8d, 0x74, 0x26, // nop
- 0x00 }; // leal 0(%esi,1),%esi
- const char nop6[6] = { 0x8d, 0xb6, 0x00, 0x00, // leal 0L(%esi),%esi
- 0x00, 0x00 };
- const char nop7[7] = { 0x8d, 0xb4, 0x26, 0x00, // leal 0L(%esi,1),%esi
- 0x00, 0x00, 0x00 };
- const char nop8[8] = { 0x90, 0x8d, 0xb4, 0x26, // nop
- 0x00, 0x00, 0x00, 0x00 }; // leal 0L(%esi,1),%esi
- const char nop9[9] = { 0x89, 0xf6, 0x8d, 0xbc, // movl %esi,%esi
- 0x27, 0x00, 0x00, 0x00, // leal 0L(%edi,1),%edi
- 0x00 };
- const char nop10[10] = { 0x8d, 0x76, 0x00, 0x8d, // leal 0(%esi),%esi
- 0xbc, 0x27, 0x00, 0x00, // leal 0L(%edi,1),%edi
- 0x00, 0x00 };
- const char nop11[11] = { 0x8d, 0x74, 0x26, 0x00, // leal 0(%esi,1),%esi
- 0x8d, 0xbc, 0x27, 0x00, // leal 0L(%edi,1),%edi
- 0x00, 0x00, 0x00 };
- const char nop12[12] = { 0x8d, 0xb6, 0x00, 0x00, // leal 0L(%esi),%esi
- 0x00, 0x00, 0x8d, 0xbf, // leal 0L(%edi),%edi
- 0x00, 0x00, 0x00, 0x00 };
- const char nop13[13] = { 0x8d, 0xb6, 0x00, 0x00, // leal 0L(%esi),%esi
- 0x00, 0x00, 0x8d, 0xbc, // leal 0L(%edi,1),%edi
- 0x27, 0x00, 0x00, 0x00,
- 0x00 };
- const char nop14[14] = { 0x8d, 0xb4, 0x26, 0x00, // leal 0L(%esi,1),%esi
- 0x00, 0x00, 0x00, 0x8d, // leal 0L(%edi,1),%edi
- 0xbc, 0x27, 0x00, 0x00,
- 0x00, 0x00 };
- const char nop15[15] = { 0xeb, 0x0d, 0x90, 0x90, // jmp .+15
- 0x90, 0x90, 0x90, 0x90, // nop,nop,nop,...
- 0x90, 0x90, 0x90, 0x90,
- 0x90, 0x90, 0x90 };
+ const char nop1[1] = { '\x90' }; // nop
+ const char nop2[2] = { '\x66', '\x90' }; // xchg %ax %ax
+ const char nop3[3] = { '\x8d', '\x76', '\x00' }; // leal 0(%esi),%esi
+ const char nop4[4] = { '\x8d', '\x74', '\x26', // leal 0(%esi,1),%esi
+ '\x00'};
+ const char nop5[5] = { '\x90', '\x8d', '\x74', // nop
+ '\x26', '\x00' }; // leal 0(%esi,1),%esi
+ const char nop6[6] = { '\x8d', '\xb6', '\x00', // leal 0L(%esi),%esi
+ '\x00', '\x00', '\x00' };
+ const char nop7[7] = { '\x8d', '\xb4', '\x26', // leal 0L(%esi,1),%esi
+ '\x00', '\x00', '\x00',
+ '\x00' };
+ const char nop8[8] = { '\x90', '\x8d', '\xb4', // nop
+ '\x26', '\x00', '\x00', // leal 0L(%esi,1),%esi
+ '\x00', '\x00' };
+ const char nop9[9] = { '\x89', '\xf6', '\x8d', // movl %esi,%esi
+ '\xbc', '\x27', '\x00', // leal 0L(%edi,1),%edi
+ '\x00', '\x00', '\x00' };
+ const char nop10[10] = { '\x8d', '\x76', '\x00', // leal 0(%esi),%esi
+ '\x8d', '\xbc', '\x27', // leal 0L(%edi,1),%edi
+ '\x00', '\x00', '\x00',
+ '\x00' };
+ const char nop11[11] = { '\x8d', '\x74', '\x26', // leal 0(%esi,1),%esi
+ '\x00', '\x8d', '\xbc', // leal 0L(%edi,1),%edi
+ '\x27', '\x00', '\x00',
+ '\x00', '\x00' };
+ const char nop12[12] = { '\x8d', '\xb6', '\x00', // leal 0L(%esi),%esi
+ '\x00', '\x00', '\x00', // leal 0L(%edi),%edi
+ '\x8d', '\xbf', '\x00',
+ '\x00', '\x00', '\x00' };
+ const char nop13[13] = { '\x8d', '\xb6', '\x00', // leal 0L(%esi),%esi
+ '\x00', '\x00', '\x00', // leal 0L(%edi,1),%edi
+ '\x8d', '\xbc', '\x27',
+ '\x00', '\x00', '\x00',
+ '\x00' };
+ const char nop14[14] = { '\x8d', '\xb4', '\x26', // leal 0L(%esi,1),%esi
+ '\x00', '\x00', '\x00', // leal 0L(%edi,1),%edi
+ '\x00', '\x8d', '\xbc',
+ '\x27', '\x00', '\x00',
+ '\x00', '\x00' };
+ const char nop15[15] = { '\xeb', '\x0d', '\x90', // jmp .+15
+ '\x90', '\x90', '\x90', // nop,nop,nop,...
+ '\x90', '\x90', '\x90',
+ '\x90', '\x90', '\x90',
+ '\x90', '\x90', '\x90' };
const char* nops[16] = {
NULL,
Index: x86_64.cc
===================================================================
RCS file: /cvs/src/src/gold/x86_64.cc,v
retrieving revision 1.141
diff -u -p -r1.141 x86_64.cc
--- x86_64.cc 31 Oct 2011 22:33:04 -0000 1.141
+++ x86_64.cc 17 Dec 2011 00:09:45 -0000
@@ -3861,42 +3861,51 @@ Target_x86_64::do_code_fill(section_size
}
// Nop sequences of various lengths.
- const char nop1[1] = { 0x90 }; // nop
- const char nop2[2] = { 0x66, 0x90 }; // xchg %ax %ax
- const char nop3[3] = { 0x0f, 0x1f, 0x00 }; // nop (%rax)
- const char nop4[4] = { 0x0f, 0x1f, 0x40, 0x00}; // nop 0(%rax)
- const char nop5[5] = { 0x0f, 0x1f, 0x44, 0x00, // nop 0(%rax,%rax,1)
- 0x00 };
- const char nop6[6] = { 0x66, 0x0f, 0x1f, 0x44, // nopw 0(%rax,%rax,1)
- 0x00, 0x00 };
- const char nop7[7] = { 0x0f, 0x1f, 0x80, 0x00, // nopl 0L(%rax)
- 0x00, 0x00, 0x00 };
- const char nop8[8] = { 0x0f, 0x1f, 0x84, 0x00, // nopl 0L(%rax,%rax,1)
- 0x00, 0x00, 0x00, 0x00 };
- const char nop9[9] = { 0x66, 0x0f, 0x1f, 0x84, // nopw 0L(%rax,%rax,1)
- 0x00, 0x00, 0x00, 0x00,
- 0x00 };
- const char nop10[10] = { 0x66, 0x2e, 0x0f, 0x1f, // nopw %cs:0L(%rax,%rax,1)
- 0x84, 0x00, 0x00, 0x00,
- 0x00, 0x00 };
- const char nop11[11] = { 0x66, 0x66, 0x2e, 0x0f, // data16
- 0x1f, 0x84, 0x00, 0x00, // nopw %cs:0L(%rax,%rax,1)
- 0x00, 0x00, 0x00 };
- const char nop12[12] = { 0x66, 0x66, 0x66, 0x2e, // data16; data16
- 0x0f, 0x1f, 0x84, 0x00, // nopw %cs:0L(%rax,%rax,1)
- 0x00, 0x00, 0x00, 0x00 };
- const char nop13[13] = { 0x66, 0x66, 0x66, 0x66, // data16; data16; data16
- 0x2e, 0x0f, 0x1f, 0x84, // nopw %cs:0L(%rax,%rax,1)
- 0x00, 0x00, 0x00, 0x00,
- 0x00 };
- const char nop14[14] = { 0x66, 0x66, 0x66, 0x66, // data16; data16; data16
- 0x66, 0x2e, 0x0f, 0x1f, // data16
- 0x84, 0x00, 0x00, 0x00, // nopw %cs:0L(%rax,%rax,1)
- 0x00, 0x00 };
- const char nop15[15] = { 0x66, 0x66, 0x66, 0x66, // data16; data16; data16
- 0x66, 0x66, 0x2e, 0x0f, // data16; data16
- 0x1f, 0x84, 0x00, 0x00, // nopw %cs:0L(%rax,%rax,1)
- 0x00, 0x00, 0x00 };
+ const char nop1[1] = { '\x90' }; // nop
+ const char nop2[2] = { '\x66', '\x90' }; // xchg %ax %ax
+ const char nop3[3] = { '\x0f', '\x1f', '\x00' }; // nop (%rax)
+ const char nop4[4] = { '\x0f', '\x1f', '\x40', // nop 0(%rax)
+ '\x00'};
+ const char nop5[5] = { '\x0f', '\x1f', '\x44', // nop 0(%rax,%rax,1)
+ '\x00', '\x00' };
+ const char nop6[6] = { '\x66', '\x0f', '\x1f', // nopw 0(%rax,%rax,1)
+ '\x44', '\x00', '\x00' };
+ const char nop7[7] = { '\x0f', '\x1f', '\x80', // nopl 0L(%rax)
+ '\x00', '\x00', '\x00',
+ '\x00' };
+ const char nop8[8] = { '\x0f', '\x1f', '\x84', // nopl 0L(%rax,%rax,1)
+ '\x00', '\x00', '\x00',
+ '\x00', '\x00' };
+ const char nop9[9] = { '\x66', '\x0f', '\x1f', // nopw 0L(%rax,%rax,1)
+ '\x84', '\x00', '\x00',
+ '\x00', '\x00', '\x00' };
+ const char nop10[10] = { '\x66', '\x2e', '\x0f', // nopw %cs:0L(%rax,%rax,1)
+ '\x1f', '\x84', '\x00',
+ '\x00', '\x00', '\x00',
+ '\x00' };
+ const char nop11[11] = { '\x66', '\x66', '\x2e', // data16
+ '\x0f', '\x1f', '\x84', // nopw %cs:0L(%rax,%rax,1)
+ '\x00', '\x00', '\x00',
+ '\x00', '\x00' };
+ const char nop12[12] = { '\x66', '\x66', '\x66', // data16; data16
+ '\x2e', '\x0f', '\x1f', // nopw %cs:0L(%rax,%rax,1)
+ '\x84', '\x00', '\x00',
+ '\x00', '\x00', '\x00' };
+ const char nop13[13] = { '\x66', '\x66', '\x66', // data16; data16; data16
+ '\x66', '\x2e', '\x0f', // nopw %cs:0L(%rax,%rax,1)
+ '\x1f', '\x84', '\x00',
+ '\x00', '\x00', '\x00',
+ '\x00' };
+ const char nop14[14] = { '\x66', '\x66', '\x66', // data16; data16; data16
+ '\x66', '\x66', '\x2e', // data16
+ '\x0f', '\x1f', '\x84', // nopw %cs:0L(%rax,%rax,1)
+ '\x00', '\x00', '\x00',
+ '\x00', '\x00' };
+ const char nop15[15] = { '\x66', '\x66', '\x66', // data16; data16; data16
+ '\x66', '\x66', '\x66', // data16; data16
+ '\x2e', '\x0f', '\x1f', // nopw %cs:0L(%rax,%rax,1)
+ '\x84', '\x00', '\x00',
+ '\x00', '\x00', '\x00' };
const char* nops[16] = {
NULL,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gold patch] Fix C++11 warnings
2011-12-17 0:14 [gold patch] Fix C++11 warnings Cary Coutant
@ 2011-12-17 1:53 ` Ian Lance Taylor
2011-12-17 22:16 ` Cary Coutant
0 siblings, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2011-12-17 1:53 UTC (permalink / raw)
To: Cary Coutant; +Cc: Binutils
Cary Coutant <ccoutant@google.com> writes:
> 2011-12-16 Cary Coutant <ccoutant@google.com>
>
> * dwarf_reader.cc (Sized_dwarf_line_info::read_lines): Add casts.
> * i386.cc (Target_i386::do_code_fill): Use char constants for nop
> arrays.
> * x86_64.cc (Target_x86_64::do_code_fill): Likewise.
This is OK.
Thanks.
Ian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gold patch] Fix C++11 warnings
2011-12-17 1:53 ` Ian Lance Taylor
@ 2011-12-17 22:16 ` Cary Coutant
2011-12-19 21:15 ` Ian Lance Taylor
0 siblings, 1 reply; 4+ messages in thread
From: Cary Coutant @ 2011-12-17 22:16 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: Binutils
>> 2011-12-16 Cary Coutant <ccoutant@google.com>
>>
>> * dwarf_reader.cc (Sized_dwarf_line_info::read_lines): Add casts.
>> * i386.cc (Target_i386::do_code_fill): Use char constants for nop
>> arrays.
>> * x86_64.cc (Target_x86_64::do_code_fill): Likewise.
>
> This is OK.
I missed one file...
-cary
* resolve.cc (Symbol_table::resolve): Likewise.
Index: resolve.cc
===================================================================
RCS file: /cvs/src/src/gold/resolve.cc,v
retrieving revision 1.64
diff -u -p -r1.64 resolve.cc
--- resolve.cc 18 Oct 2011 00:25:52 -0000 1.64
+++ resolve.cc 17 Dec 2011 22:08:42 -0000
@@ -336,9 +336,9 @@ Symbol_table::resolve(Sized_symbol<size>
&& to->name()[0] == '_' && to->name()[1] == 'Z')
{
Symbol_location fromloc
- = { object, orig_st_shndx, sym.get_st_value() };
+ = { object, orig_st_shndx, static_cast<off_t>(sym.get_st_value()) };
Symbol_location toloc = { to->object(), to->shndx(&to_is_ordinary),
- to->value() };
+ static_cast<off_t>(to->value()) };
this->candidate_odr_violations_[to->name()].insert(fromloc);
this->candidate_odr_violations_[to->name()].insert(toloc);
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gold patch] Fix C++11 warnings
2011-12-17 22:16 ` Cary Coutant
@ 2011-12-19 21:15 ` Ian Lance Taylor
0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2011-12-19 21:15 UTC (permalink / raw)
To: Cary Coutant; +Cc: Binutils
On Sat, Dec 17, 2011 at 2:16 PM, Cary Coutant <ccoutant@google.com> wrote:
>>> 2011-12-16 Cary Coutant <ccoutant@google.com>
>>>
>>> * dwarf_reader.cc (Sized_dwarf_line_info::read_lines): Add casts.
>>> * i386.cc (Target_i386::do_code_fill): Use char constants for nop
>>> arrays.
>>> * x86_64.cc (Target_x86_64::do_code_fill): Likewise.
>>
>> This is OK.
>
> I missed one file...
>
> * resolve.cc (Symbol_table::resolve): Likewise.
I copied the final patch over to the binutils 2.22 branch.
I also committed some changes to the binutils 2.22 branch which I
reported earlier but somehow failed to commit.
Ian
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-12-19 21:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-17 0:14 [gold patch] Fix C++11 warnings Cary Coutant
2011-12-17 1:53 ` Ian Lance Taylor
2011-12-17 22:16 ` Cary Coutant
2011-12-19 21:15 ` Ian Lance Taylor
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).